Here's an example of how to create an HTTP server on a specific port in Python using the socket
module:
main.py981 chars38 lines
This code creates a TCP/IP socket and binds it to a specific address and port (127.0.0.1:8000
in this case). It then listens for incoming connections, and for each connection it receives, it sends an HTTP response header and content back to the client. The code will run indefinitely until you stop it manually or an error occurs.
gistlibby LogSnag