def render(self, environ, start_response):
        verb = environ.get('REQUEST_METHOD', 'GET').strip().upper()
        if verb not in ('GET', 'POST'):
            response = Response('405 Method Not Allowed', status=405,
                                mimetype='text/plain')
            response.headers['Allow'] = 'GET, POST'
            return response(environ, start_response)

        # handle on/off switch
        if verb == 'POST':
            try:
                clen = int(environ.get('CONTENT_LENGTH', '0'))
            except __HOLE__:
                clen = 0
            body = environ['wsgi.input'].read(clen).decode('utf-8')
            body = urlparse.parse_qs(body)
            clear = body.get('clear', None)
            if clear:
                del self.stats[:]
                return self.render_response(environ, start_response)

            turn = body.get('turn', ' ')[0].strip().lower()
            if turn not in ('on', 'off'):
                response = Response('400 Bad Request: parameter '
                                    '"turn=(on|off)" required',
                                    status='400', mimetype='text/plain')
                return response(environ, start_response)
            if turn == 'on':
                self.start()
            else:
                self.stop()

        try:
            while True:
                self.stats.append(self.collector.get(block=False))
        except queue.Empty:
            pass

        return self.render_response(environ, start_response)
dataset/ETHPy150Open inconshreveable/sqltap/sqltap/wsgi.py/SQLTapMiddleware.render