[英]flask before_request can't access request variable
I have a simple flask app:我有一个简单的 flask 应用程序:
def create_app():
config_name = 'testing_local'
app = Flask(__name__)
app.config.from_object(CONFIG_BY_NAME[config_name])
app.url_map.converters['bool'] = BooleanConverter
@app.before_request
def incoming_request_logging():
print(request)
return app
I get the error:我得到错误:
Undefined variable 'request'
I thought the wrapper included the request object when called?我认为包装器在调用时包含了请求 object?
In this example , first approved answer seems like the request object is inherited? 在这个例子中,第一个批准的答案似乎是继承了请求 object? Can anyone link me to a full example?
谁能把我链接到一个完整的例子? How can I retrieve this variable?
如何检索此变量?
I guess declaring this at top of your program might solve your issue, if I think what you said it is:我想在你的程序顶部声明它可能会解决你的问题,如果我认为你所说的是:
from flask import request
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.