clean up dev-server stuff, and construct memcache client..
authorTero Marttila <terom@fixme.fi>
Tue, 26 Jan 2010 01:37:30 +0200
changeset 106 26f10ed59c8e
parent 105 30c091643f75
child 107 9fcf58fb113a
clean up dev-server stuff, and construct memcache client..
bin/dev-server
--- a/bin/dev-server	Tue Jan 26 01:37:16 2010 +0200
+++ b/bin/dev-server	Tue Jan 26 01:37:30 2010 +0200
@@ -3,19 +3,22 @@
 import wsgiref.simple_server
 import werkzeug
 from werkzeug.exceptions import NotFound
+import memcache
 
 import pngtile.wsgi
 
-def main (host='0.0.0.0', port=8000) :
-    # original app
-    app = pngtile.wsgi.WSGIApplication()
+def main (host='0.0.0.0', port=8000, memcache_host='localhost:11211') :
+    print "Using memcache server at %s" % memcache_host
 
-    # dispatch on URL
-    # XXX: just replace with SharedDataMiddleware..
-    app = werkzeug.DispatcherMiddleware(app, {
-        '/static':      werkzeug.SharedDataMiddleware(NotFound(), {
-            '/':            'static',
-        }),
+    # cache
+    cache = memcache.Client([memcache_host])
+
+    # original app
+    app = pngtile.wsgi.WSGIApplication(cache)
+
+    # serve up static content as well
+    app = werkzeug.SharedDataMiddleware(app, {
+        '/static':          'static',
     })
     
     # http server