Here's my situation:
Let's say I have 2 Blueprints before_request method:
mod = Blueprint('posts', __name__, url_prefix='/posts')
@mod.before_request
def before_request():
#some code that uses SQLAlchemy here
pass
Now I don't want to duplicate the logic in this method in the second blueprint.
How can I do this?
PS: I'm new to Python so I might be missing something obvious. Thanks.
使用blueprint.before_app_request
,它适用于应用程序范围内的视图,而不仅仅适用于同一蓝图中的视图
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.