Skip to content

Instantly share code, notes, and snippets.

@FreedomKnight
Created January 10, 2014 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FreedomKnight/8355822 to your computer and use it in GitHub Desktop.
Save FreedomKnight/8355822 to your computer and use it in GitHub Desktop.
Hello World Web Server
#!/usr/bin/env python
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(('localhost', 80))
sock.listen(5)
while True:
connection, address = sock.accept()
buf = connection.recv(1024)
httpString = b"""\
HTTP/1.1 200 OK\r
\r
<h1> hello </h1>\r
"""
connection.send(httpString)
connection.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment