pixied.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:pixie 作者: algorithm-ninja 项目源码 文件源码
def wsgi_app(self, environ, start_response):
        route = self.router.bind_to_environ(environ)
        try:
            endpoint, args = route.match()
        except RequestRedirect as e:
            return e
        except HTTPException:
            return NotFound()

        request = Request(environ)
        get_args = dict(request.args)
        if endpoint == 'wipe':
            get_args['wipe'] = 'pixie_wipe=force'
        else:
            get_args['wipe'] = ""


        response = Response()
        response.mimetype = 'text/plain'
        response.status_code = 200

        config = None
        if 'ip' in get_args:
            ip_addr = ipaddress.ip_address(get_args['ip'][0])
            for cfg in self.configs:
                if ip_addr in cfg['subnet']:
                    config = cfg

        if config is None:
            response.data = CONFIGSCRIPT.format(**self.default_config)
        else:
            for (k, v) in config.items():
                get_args[k] = v
            response.data = BOOTSCRIPT.format(**get_args)
        return response
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号