def __call__(self, environ, start_response):
        response_status = "200 OK"
        mime_type = 'text/html'
        fmt = 'png'
        if not self._locked:
            path_info = environ['PATH_INFO']
            qs = environ['QUERY_STRING']    
            zoom,x,y = None,None,None
            if qs:
                query = parse_query(qs)
                x = query.get('x')
                y = query.get('y')
                zoom = query.get('z')
                if x and y and zoom:
                    x = int(x)
                    y = int(y)
                    zoom = int(zoom)
                fmt = query.get('format','png')
            elif is_image_request(path_info):
                uri, fmt = path_info.split('.')
                zoom,x,y = map(int,uri.split('/')[-3:])
            if self.paletted:
                fmt = 'png256'
            if (x is not None) and (y is not None) and (zoom is not None):
                response = self.render(zoom, x, y, fmt)
                mime_type = 'image/%s' % fmt
                self.msg('Zoom,X,Y: %s,%s,%s' % (zoom,x,y,))
                self.msg('scale_denom: %s' % (self._mapnik_map.scale_denominator()))
            elif path_info.endswith('settings/'):
                response = '<h2>TileLite Settings</h2>'
                response += '<pre style="%s">%s</pre>' % (CSS_STYLE,self.settings())
                if self._config:
                    response += '<h4>From: %s</h4>' % self._config
                else:
                    response += '<h4>*default settings*</h4>'
            elif path_info.endswith('settings.json'):
                response = str(self.settings_dict())
                mime_type = 'text/plain'        
            elif path_info.endswith('instance.json'):
                if 'jsoncallback' in query:
                    response = ('%s(%s);' % (query['jsoncallback'], self.instance_dict()))
                    mime_type = 'application/json'
                else:
                    response = str(self.instance_dict())
                    mime_type = 'text/plain'
            elif not path_info.strip('/'):
                root = '%s%s' % (environ['SCRIPT_NAME'], path_info.strip('/'))
                response = '''<h2>TileLite</h2>
                <div style="%(style)s"><p>Welcome, ready to accept a tile request in the format of:</p>
                <p>%(root)s/zoom/x/y.png</p>
                <p>or</p>
                <p>%(root)s/?x=0&y=0&z=0&format=png</p>
                <p>Example url: <a href="%(root)s/1/0/0.png">%(root)s/1/0/0.png</a></p>
                <p>See TileLite settings: <a href="%(root)s/settings/">%(root)s/settings/</a>
                | <a href="%(root)s/settings.json">%(root)s/settings.json</a></p>
                <p> More info: <a href="https://github.com/springmeyer/tilelite/">
                github.com/springmeyer/tilelite</a></p></div>
                ''' % {'root': root,'style':CSS_STYLE,'http_host':environ['HTTP_HOST']}
            else:
                response = '<h1> Page Not found </h1>'
                response_status = "404 Not Found"
        else:
            mime_type = 'image/%s' % fmt
            im = mapnik.Image(self.size,self.size)
            im.background = mapnik.Color('pink')
            response = im.tostring(fmt)
                        
        #self.msg('Multithreaded: %s | Multiprocess: %s' % (environ['wsgi.multithread'],environ['wsgi.multiprocess']))
        start_response(response_status,[('Content-Type', mime_type)])
        yield response
WSGI request handler
dataset/ETHPy150Open springmeyer/tilelite/tilelite.py/Server.__call__