Last active
August 17, 2017 22:19
-
-
Save leslie-wang/5a3b31a703c44c3bff4ad45feb57eecf to your computer and use it in GitHub Desktop.
Simple HTTP Server for HTTP 1.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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