]> khamidou — GitHub mirrors - minus.git/commitdiff
initial commit master
authorkhamidou <khamidou@gmail.com>
Fri, 3 Sep 2010 17:36:18 +0000 (19:36 +0200)
committerkhamidou <khamidou@gmail.com>
Fri, 3 Sep 2010 17:36:18 +0000 (19:36 +0200)
README [new file with mode: 0644]
minus.py [new file with mode: 0644]
testapp.py [new file with mode: 0644]

diff --git a/README b/README
new file mode 100644 (file)
index 0000000..192ef34
--- /dev/null
+++ b/README
@@ -0,0 +1,2 @@
+This is minus, a simple wsgi framework. It is not intended to be usable for other purposes
+than education.
diff --git a/minus.py b/minus.py
new file mode 100644 (file)
index 0000000..c7edb1c
--- /dev/null
+++ b/minus.py
@@ -0,0 +1,33 @@
+# minus - a microframework in python
+
+from wsgiref.util import setup_testing_defaults
+from wsgiref.simple_server import make_server
+
+class View(object):
+       def __init__(self):
+               self.status = b'200 OK' # By default, everything is always right
+               self.headers = [(b'Content-type', b'text/plain; charset=utf-8')]
+
+       def do_GET(self):
+               pass
+       
+       def do_POST(self):
+               pass
+
+class App(object):
+       def __init__(self, routings):
+               self.routings = routings
+
+       def __call__(self, environ, start_response):
+               if environ["PATH_INFO"] in self.routings:
+                       view = self.routings[environ["PATH_INFO"]]()
+
+                       if environ["REQUEST_METHOD"] == "GET":
+                               response = view.do_GET()
+                               start_response(view.status, view.headers)
+                               return response
+               
+def run(app):
+       httpd = make_server('', 8000, app)
+       print("Serving on http://localhost:8000")
+       httpd.serve_forever()
diff --git a/testapp.py b/testapp.py
new file mode 100644 (file)
index 0000000..48baae6
--- /dev/null
@@ -0,0 +1,9 @@
+from minus import *
+
+class minusApp(View):
+       def do_GET(self):
+               return "OH HAI"
+
+routes = {"/" : minusApp} 
+app = App(routes)
+run(app)