Created
April 16, 2011 22:06
-
-
Save ncweinhold/923546 to your computer and use it in GitHub Desktop.
quick 5 minute script to simple serve a hard coded page
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 gevent import monkey | |
from gevent import wsgi | |
monkey.patch_all() | |
PORT = 8080 | |
SIMPLE_PAGE = """<html><head><title>Simple Page</title></head><body><h1>Hello World</h1><p>Simple Gevent Page</p></body></html>""" | |
def application(env, start_response): | |
method = env['REQUEST_METHOD'] | |
path = env['PATH_INFO'] | |
if (method, path) == ('GET', '/'): | |
start_response('200 OK', [('Content-Type', 'text/html')]) | |
return [SIMPLE_PAGE] | |
else: | |
start_response('404 Not Found', []) | |
return [] | |
if __name__ == "__main__": | |
print "Serving on %s..." % PORT | |
wsgi.WSGIServer(('', PORT), application).serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment