Skip to content

Instantly share code, notes, and snippets.

@thomasballinger
Created October 4, 2012 21:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasballinger/3836614 to your computer and use it in GitHub Desktop.
Save thomasballinger/3836614 to your computer and use it in GitHub Desktop.
wsgi example
def myapp(environ):
print environ
query_string = environ['QUERY_STRING']
return '<html><body>hello<body></html>'
def hello_world_app(environ, start_response):
status = '200 OK' # HTTP Status
headers = [('Content-type', 'text/plain')] # HTTP Headers
start_response(status, headers)
response = myapp(environ)
# The returned object is going to be printed
return [response]
from wsgiref.simple_server import make_server
httpd = make_server('', 8000, hello_world_app)
print "Serving on port 8000..."
httpd.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment