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_APPisn't set that will probably serve you well enough.wsgi.pyorapp.pyin the current directory.apporapplication, if it's aFlaskobject return it.Flaskand return that.create_appormake_app. Call it without arguments, if it returns aFlaskobject return it.I'd suggest extending this to looking in
__init__.pyandapp.pyfiles 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…