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
If you have a file AppName.py
in which you define app
, and then you have another file Foobar.py
that needs it, you can always say in AppName.py
:
import Foobar
Foobar.app = app
Then in Foobar.py
you should be able to use app in your functions. One thing you want to be careful of is that you can't have code in Foobar.py
that runs immediately when the file is called the depends on the app
variable which is passed in after the import.