2015-04-12 01:10:35 +01:00
|
|
|
import sys
|
|
|
|
import BaseHTTPServer
|
|
|
|
from SimpleHTTPServer import SimpleHTTPRequestHandler
|
|
|
|
|
|
|
|
|
|
|
|
HandlerClass = SimpleHTTPRequestHandler
|
|
|
|
ServerClass = BaseHTTPServer.HTTPServer
|
|
|
|
Protocol = "HTTP/1.0"
|
|
|
|
|
|
|
|
if sys.argv[1:]:
|
|
|
|
port = int(sys.argv[1])
|
|
|
|
else:
|
2016-06-07 21:25:20 -04:00
|
|
|
port = 0
|
2017-02-22 16:56:14 -05:00
|
|
|
server_address = ('127.0.0.1', port)
|
2015-04-12 01:10:35 +01:00
|
|
|
|
|
|
|
HandlerClass.protocol_version = Protocol
|
|
|
|
httpd = ServerClass(server_address, HandlerClass)
|
|
|
|
|
2017-02-22 16:56:14 -05:00
|
|
|
ip, port = httpd.socket.getsockname()[0:2]
|
|
|
|
print ("Server started, http://%s:%s/" % (ip, port))
|
|
|
|
# Flush in case we're in full buffering mode (instead of line
|
|
|
|
# buffering), this might happen if python is a cygwin program and we
|
|
|
|
# run it from a native w32 program.
|
|
|
|
sys.stdout.flush()
|
2015-04-12 01:10:35 +01:00
|
|
|
httpd.serve_forever()
|