Flask - 如何使用装饰器从app.before_request中排除路线?

时间:2017-06-09 12:32:47

标签: python flask

如何从app.before_request功能中排除某些功能。我知道你可以查看request.endpoint,但我希望使用装饰器来实现此功能。有什么想法吗?

1 个答案:

答案 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.