Add python-eventlet 0.16.1
[packages/trusty/python-eventlet.git] / eventlet / examples / wsgi.py
diff --git a/eventlet/examples/wsgi.py b/eventlet/examples/wsgi.py
new file mode 100644 (file)
index 0000000..05668a4
--- /dev/null
@@ -0,0 +1,19 @@
+"""This is a simple example of running a wsgi application with eventlet.
+For a more fully-featured server which supports multiple processes,
+multiple threads, and graceful code reloading, see:
+
+http://pypi.python.org/pypi/Spawning/
+"""
+
+import eventlet
+from eventlet import wsgi
+
+
+def hello_world(env, start_response):
+    if env['PATH_INFO'] != '/':
+        start_response('404 Not Found', [('Content-Type', 'text/plain')])
+        return ['Not Found\r\n']
+    start_response('200 OK', [('Content-Type', 'text/plain')])
+    return ['Hello, World!\r\n']
+
+wsgi.server(eventlet.listen(('', 8090)), hello_world)