【发布时间】:2020-08-13 00:04:24
【问题描述】:
我正在学习烧瓶和 python,但我无法理解典型烧瓶应用程序需要构建的方式。
我需要从蓝图中访问应用配置。像这样的
#blueprint.py
from flask import Blueprint
sample_blueprint = Blueprint("sample", __name__)
# defining a route for this blueprint
@sample_blueprint.route("/")
def index():
# !this is the problematic line
# need to access some config from the app
x = app.config["SOMETHING"]
# how to access app inside blueprint?
如果在蓝图中导入应用程序是解决方案,这不会导致循环导入吗?即在应用中导入蓝图,在蓝图中导入应用?
【问题讨论】:
标签: design-patterns flask