[SCRIPT] serve.py: display the address of the URL used by the server (copy/paste).

master
frozar 6 years ago committed by David O'Connor
parent 0d028f4a9d
commit 5942fe3a5b

@ -27,15 +27,15 @@ handler.extensions_map.update({
})
socketserver.TCPServer.allow_reuse_address = True
print("Serving at port", PORT)
print("View at: http://localhost:{}/".format(PORT))
# The context manager protocol is support only since python 3.6 and higher.
if (3 <= sys.version_info[0]) and (6 <= sys.version_info[1]):
with socketserver.TCPServer(("", PORT), handler) as httpd:
httpd.allow_reuse_address = True
print("Serving at port", PORT)
httpd.serve_forever()
else:
httpd = socketserver.TCPServer(("", PORT), handler)
httpd.allow_reuse_address = True
print("Serving at port", PORT)
httpd.serve_forever()
httpd.serve_close()

Loading…
Cancel
Save