Skip to content

Instantly share code, notes, and snippets.

@ncweinhold
Created April 16, 2011 22:06
Show Gist options
  • Save ncweinhold/923546 to your computer and use it in GitHub Desktop.
Save ncweinhold/923546 to your computer and use it in GitHub Desktop.
quick 5 minute script to simple serve a hard coded page
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