How to share the global app object in flask?

后端 未结 6 669
被撕碎了的回忆
被撕碎了的回忆 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:06

    First, I would suggest to take a look at Blueprints http://flask.pocoo.org/docs/blueprints/ This will help to organize the app easily.

    Also take a look at http://flask.pocoo.org/docs/api/#flask.current_app flask.current_app, the way how to get your app instance in other modules.

    This link also could be helpful on how to organize and build flask app (it is not ideal for sure, but can give you some ideas) - Large-app-how-to.md

    Have fun :)

提交回复
热议问题