Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在after_请求中捕获瓶装响应中的JSON?_Python_Bottle - Fatal编程技术网

Python 如何在after_请求中捕获瓶装响应中的JSON?

Python 如何在after_请求中捕获瓶装响应中的JSON?,python,bottle,Python,Bottle,我想用Bootle Py记录所有web服务响应。 最好的方法是什么 我正在使用以下代码写入MongoDB数据库: @hook('after_request') def f_after_request(): if request['bottle.route'].rule not in [ '/robots.txt', '/favicon.ico', ]: json_in = None if request.method

我想用Bootle Py记录所有web服务响应。 最好的方法是什么

我正在使用以下代码写入MongoDB数据库:

@hook('after_request')
def f_after_request():
    if request['bottle.route'].rule not in [
        '/robots.txt',
        '/favicon.ico',
    ]:
        json_in = None
        if request.method not in ['GET']:
            json_in = request.json
        _save_in_out_message(
            url=bottle.request.url,
            json_in=json_in,
            json_out=bottle.response.get_data(),
            status_code=response.status_code,
            method=request.method
        )
但是
response.get_data()
不存在

如何在after_请求中捕获瓶装响应中的JSON

什么是正确的
响应。获取数据()
命令

谢谢

请参阅。建议使用类似插件的