How to access app.config in a blueprint?

前端 未结 7 980
没有蜡笔的小新
没有蜡笔的小新 2020-12-12 23:07

I am trying to access access application configuration inside a blueprint authorisation.py which in a package api. I am initializing the blueprint in __in

7条回答
  •  情深已故
    2020-12-12 23:36

    Use flask.current_app in place of app in the blueprint view.

    from flask import current_app
    
    @api.route("/info")
    def get_account_num():
        num = current_app.config["INFO"]
    

    The current_app proxy is only available in the context of a request.

提交回复
热议问题