pngtile/wsgi.py
changeset 148 2a2d2d6f6f80
parent 147 77330e43c855
child 149 176a656031cb
equal deleted inserted replaced
147:77330e43c855 148:2a2d2d6f6f80
     1 """
       
     2     Our WSGI web interface, which can serve the JS UI and any .png tiles via HTTP.
       
     3 """
       
     4 
       
     5 from werkzeug import Request, responder
       
     6 from werkzeug import exceptions
       
     7 
       
     8 from pngtile import handlers
       
     9 
       
    10 
       
    11 class WSGIApplication (object) :
       
    12     """
       
    13         Simple WSGI application invoking the werkzeug handlers
       
    14     """
       
    15 
       
    16     def __init__ (self, cache=None) :
       
    17         """
       
    18             Use given cache if any
       
    19         """
       
    20 
       
    21         self.cache = cache
       
    22 
       
    23     @responder
       
    24     def __call__ (self, env, start_response) :
       
    25         """
       
    26             Main WSGI entry point.
       
    27 
       
    28             This is wrapped with werkzeug, so we can return a Response object
       
    29         """
       
    30 
       
    31         req = Request(env, start_response)
       
    32         
       
    33         try :
       
    34             return handlers.handle_req(req, self.cache)
       
    35 
       
    36         except exceptions.HTTPException, e :
       
    37             return e
       
    38