Skip to content

Instantly share code, notes, and snippets.

@Kyle-Falconer
Created October 2, 2015 17:04
Show Gist options
  • Save Kyle-Falconer/20d73f1db0ccd16ec816 to your computer and use it in GitHub Desktop.
Save Kyle-Falconer/20d73f1db0ccd16ec816 to your computer and use it in GitHub Desktop.
simple webserver for Python 3, with commented notes for one-liner web service.
# Python 2:
# python -m SimpleHTTPServer
#
# Python 3:
# python -m http.server
import http.server
def start_server(port=8000, bind="", cgi=False):
if cgi==True:
http.server.test(HandlerClass=http.server.CGIHTTPRequestHandler, port=port, bind=bind)
else:
http.server.test(HandlerClass=http.server.SimpleHTTPRequestHandler,port=port,bind=bind)
start_server() #If you want cgi, set cgi to True e.g. start_server(cgi=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment