Created
June 18, 2015 15:23
-
-
Save akshar-raaj/f2500270c6f92631e1d1 to your computer and use it in GitHub Desktop.
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
#application.py | |
from wsgiref.simple_server import make_server | |
# This is the "Application side" of WSGI | |
def application(environ, start_response): | |
path = environ.get('PATH_INFO') | |
if path == '/': | |
response_body = 'Index' | |
else: | |
response_body = "Hello" | |
status = "200 OK" | |
response_headers = [("Content-Length", str(len(response_body)))] | |
start_response(status, response_headers) | |
return [response_body] | |
# make_server() creates the "Server side" of WSGI | |
# Also note that the "application side" of WSGI is passed while creating | |
# the "Server side". | |
httpd = make_server('localhost', 8051, application) | |
print "Server running at http://localhost:8051" | |
httpd.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment