Created
October 4, 2012 21:36
-
-
Save thomasballinger/3836614 to your computer and use it in GitHub Desktop.
wsgi example
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
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