Created
April 18, 2016 10:32
-
-
Save nonZero/fd5c6ac97ce9ede20953c450e885bc5b to your computer and use it in GitHub Desktop.
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
# 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