]> khamidou — GitHub mirrors - miniwsgi.git/commitdiff
working on basic routin
authorkarim hamidou <khamidou@gmail.com>
Tue, 15 May 2012 19:20:56 +0000 (21:20 +0200)
committerkarim hamidou <khamidou@gmail.com>
Tue, 15 May 2012 19:20:56 +0000 (21:20 +0200)
__init__.py [new file with mode: 0644]

diff --git a/__init__.py b/__init__.py
new file mode 100644 (file)
index 0000000..d0db2a0
--- /dev/null
@@ -0,0 +1,17 @@
+from wsgiref.simple_server import make_server, demo_app
+
+urls = {}
+
+def handle_requests(environ, start_response):
+    method = environ['REQUEST_METHOD'].upper() # get the request method
+    path = environ['PATH_INFO'] 
+
+    # then, lookup if there's a matching route:
+    if path in urls:
+        start_response('200 OK', [('content-type', 'text/html')])
+        return urls["GET"][path]()
+            
+def run(urls):
+    httpd = make_server('', 8000, handle_requests)
+    print "Serving HTTP on http://localhost:8000"
+    httpd.serve_forever()