Last active
August 29, 2015 14:03
-
-
Save return-none/c91f55ac8be443b83c96 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python | |
""" | |
Simple python HTTP server. Added nice messages. | |
Place to /usr/local/bin/serve, chmod and run. Provide port as second argument | |
TODO: handle port is busy excepion | |
""" | |
from sys import argv | |
import SimpleHTTPServer | |
import SocketServer | |
PORT = int(argv[1]) if argv[1:] else 8000 | |
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler | |
httpd = SocketServer.TCPServer(("", PORT), Handler) | |
print "serving at port", PORT | |
try: | |
httpd.serve_forever() | |
except KeyboardInterrupt: | |
pass | |
httpd.server_close() | |
print "Server stopped" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment