Created
March 20, 2013 16:43
-
-
Save keithshep/5206200 to your computer and use it in GitHub Desktop.
a minimal "hello world" wsgi application
This file contains 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
from cgi import parse_qs, escape | |
def application(environ, start_response): | |
parameters = parse_qs(environ.get('QUERY_STRING', '')) | |
if 'subject' in parameters: | |
subject = escape(parameters['subject'][0]) | |
else: | |
subject = 'World' | |
start_response('200 OK', [('Content-Type', 'text/html')]) | |
return ['Hello %(subject)s' % {'subject': subject}] | |
if __name__ == '__main__': | |
from wsgiref.simple_server import make_server | |
srv = make_server('localhost', 8080, application) | |
srv.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment