Flask: How to run a method before every route in a blueprint?
You can use the before_request decorator for blueprints. Like this:
@section.before_requestdef my_method(): do_stuff
This automatically registers the function to run before any routes that belong to the blueprint.
You can use before_request
for this:
@section.before_requestdef before_request(): do_stuff
http://flask.pocoo.org/docs/0.10/api/#flask.Flask.before_request