Skip to content

Instantly share code, notes, and snippets.

@akshar-raaj
Created June 18, 2015 15:23
Show Gist options
  • Save akshar-raaj/f2500270c6f92631e1d1 to your computer and use it in GitHub Desktop.
Save akshar-raaj/f2500270c6f92631e1d1 to your computer and use it in GitHub Desktop.
#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