bin/dev-server
changeset 106 26f10ed59c8e
parent 103 1a6a6957197d
equal deleted inserted replaced
105:30c091643f75 106:26f10ed59c8e
     1 #!/usr/bin/python
     1 #!/usr/bin/python
     2 
     2 
     3 import wsgiref.simple_server
     3 import wsgiref.simple_server
     4 import werkzeug
     4 import werkzeug
     5 from werkzeug.exceptions import NotFound
     5 from werkzeug.exceptions import NotFound
       
     6 import memcache
     6 
     7 
     7 import pngtile.wsgi
     8 import pngtile.wsgi
     8 
     9 
     9 def main (host='0.0.0.0', port=8000) :
    10 def main (host='0.0.0.0', port=8000, memcache_host='localhost:11211') :
       
    11     print "Using memcache server at %s" % memcache_host
       
    12 
       
    13     # cache
       
    14     cache = memcache.Client([memcache_host])
       
    15 
    10     # original app
    16     # original app
    11     app = pngtile.wsgi.WSGIApplication()
    17     app = pngtile.wsgi.WSGIApplication(cache)
    12 
    18 
    13     # dispatch on URL
    19     # serve up static content as well
    14     # XXX: just replace with SharedDataMiddleware..
    20     app = werkzeug.SharedDataMiddleware(app, {
    15     app = werkzeug.DispatcherMiddleware(app, {
    21         '/static':          'static',
    16         '/static':      werkzeug.SharedDataMiddleware(NotFound(), {
       
    17             '/':            'static',
       
    18         }),
       
    19     })
    22     })
    20     
    23     
    21     # http server
    24     # http server
    22     httpd = wsgiref.simple_server.make_server(host, port, app)
    25     httpd = wsgiref.simple_server.make_server(host, port, app)
    23 
    26