如何从app.before_request
功能中排除某些功能。我知道你可以查看request.endpoint
,但我希望使用装饰器来实现此功能。有什么想法吗?
答案 0 :(得分:1)
This has a solution here already - Flask hit decorator before before_request signal fires
What basically you end up doing is to define a normal function where you set the exclusion flag and then add it as decorator to all the routes you do not want to be included in the before_request call and then in your before_request where you check for the presence of that said exclusion flag and do things accordingly.