How to share the global app object in flask?

后端 未结 6 675
被撕碎了的回忆
被撕碎了的回忆 2021-01-30 16:28

I am using flask and trying to the following.

I have defined a main.py file through which I want to run my app ie python main.py -

from flask import Fla         


        
6条回答
  •  攒了一身酷
    2021-01-30 17:01

    You can import current_app from flask. It stores a reference to the global application object.

    from flask import current_app as app
    
    def home():
        return render_template('base.html', name=app.name)
    

提交回复
热议问题