I'm learning flask and python and cannot wrap my head around the way a typical flask application needs to be structured.
I need to access the app config from inside blueprint. Something like this
#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?
If importing app in blueprint is the solution, will this not result in circulat imports? i.e importing blueprint in app, importing app in blueprints?
Aucun commentaire:
Enregistrer un commentaire