From 937c478a410c3653908e8046366eefa550f3df6f Mon Sep 17 00:00:00 2001 From: karim hamidou Date: Tue, 15 May 2012 21:20:56 +0200 Subject: [PATCH] working on basic routin --- __init__.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 __init__.py diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..d0db2a0 --- /dev/null +++ b/__init__.py @@ -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() -- 2.43.0