Skip to content

Instantly share code, notes, and snippets.

@nonZero
Created April 18, 2016 10:32
Show Gist options
  • Save nonZero/fd5c6ac97ce9ede20953c450e885bc5b to your computer and use it in GitHub Desktop.
Save nonZero/fd5c6ac97ce9ede20953c450e885bc5b to your computer and use it in GitHub Desktop.
# http://wsgi.tutorial.codepoint.net/environment-dictionary
# =================================================================
# THE WSGI APPLICATION
# =================================================================
def simple_app(environ, start_response):
status = '200 OK'
response_headers = [
('Content-type', 'text/plain'),
('X-Secret', 'xyzzy'),
]
body = b"Hello world!!!!!!!!!\n"
start_response(status, response_headers)
return [body]
# =================================================================
# CREATE A WSGI SERVER
# =================================================================
from wsgiref.simple_server import make_server
# Instantiate the server
HOST = 'localhost'
PORT = 8765
httpd = make_server(HOST, PORT, simple_app)
print("Serving on http://{}:{}/".format(HOST, PORT))
# start serving
httpd.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment