What is the best way to programmatically know what module to set FLASK_APP
to?
#4660
-
For the Python extension in VS Code, we want to provide automatic debug configurations for Flask users when we can easily do so. That means (we think) needing to know what module to set |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Some ideas that come to my mind:
|
Beta Was this translation helpful? Give feedback.
-
Flask itself has some detection for when
I'd suggest extending this to looking in If you can't detect something automatically using the rules above, or even if you can, I'd suggest looking at PyCharm Professional's Flask server run configuration. It can detect what to run in many cases (probably the rules above), and then allows customizing them further to support the full range of what |
Beta Was this translation helpful? Give feedback.
-
Thanks for you reply @davidism, I was going through the arguments we have in the python extension debugger and wanted to ask why in the previous comment you suggested disabling the Flask debugger and reloader. Since on the user side it is better if these are activated. So I wanted to confirm if there is a known bug for leaving these options active, so I can leave them active by default. Thanks |
Beta Was this translation helpful? Give feedback.
Flask itself has some detection for when
FLASK_APP
isn't set that will probably serve you well enough.wsgi.py
orapp.py
in the current directory.app
orapplication
, if it's aFlask
object return it.Flask
and return that.create_app
ormake_app
. Call it without arguments, if it returns aFlask
object return it.I'd suggest extending this to looking in
__init__.py
andapp.py
files within the packages in the current project, something VS Code should be able to figure out which Flask itself can't. And since you're not actually executing code, look forvar…