Flask blueprint how do multiple routes use the same before_request method?

I have registered multiple routes using the blueprint. For example, @ admin.route and @ home.route, now define a before_request method, which I used in @ admin.before_request, and now I want to use it in @ home. What should I do? You don"t have to redefine this method in every file, do you?

Oct.15,2021

before_request is defined by you, right? Use different blueprints of before_request to decorate this function (you can call it by defining two functions, and then home.before_request and admin.before_request modify two functions respectively)


before_request the method requires you to redefine it in a different blueprint.

Menu