Skip to content

Instantly share code, notes, and snippets.

@leslie-wang
Last active August 17, 2017 22:19
Show Gist options
  • Save leslie-wang/5a3b31a703c44c3bff4ad45feb57eecf to your computer and use it in GitHub Desktop.
Save leslie-wang/5a3b31a703c44c3bff4ad45feb57eecf to your computer and use it in GitHub Desktop.
Simple HTTP Server for HTTP 1.1
import sys
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
HandlerClass = SimpleHTTPRequestHandler
ServerClass = BaseHTTPServer.HTTPServer
Protocol = "HTTP/1.1"
if sys.argv[1:]:
port = int(sys.argv[1])
else:
port = 8000
server_address = ('0.0.0.0', port)
HandlerClass.protocol_version = Protocol
httpd = ServerClass(server_address, HandlerClass)
sa = httpd.socket.getsockname()
print "Serving HTTP on", sa[0], "port", sa[1], "..."
httpd.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment