pythonflaskparametersblueprint

Python - Flask blueprint parameter?


I need to pass a parameter (some_url) from the main app to the blueprint using Flask

This is my (oversimplified) app

app = Flask(__name__)
app.register_blueprint(my_bp, url_prefix='/mybp', some_url ="http....")

This is my (oversimplified) blueprint

my_bp = Blueprint('mybp', __name__, url_prefix='/mybp')

@repositories_bp.route('/entrypoint', methods=['GET', 'POST'])
def entrypoint():
    some_url = ????

Not sure this is the way to go, but I parsed countless threads, I just cannot find any Info about this

Thanks for your help


Solution

  • you can use g object for the current request which stores temporary data, or you can use session to maintain data between multiple requests which usually stores this data in the client browser as a cookie, or you can store the data in the app.config to maintain a constant value.