这是 Visual studio code 中 Launch.JSON 文件的配置片段:
{
"name": "Python: Flask (0.11.x or later)",
"type": "python",
"request": "launch",
"module": "flask",
"env": {
//"FLASK_APP": "${workspaceFolder}/
microblog.py"
"FLASK_APP": "
microblog.py",
"FLASK_DEBUG": "1"
},
"args": [
"run",
//"--no-debugger",
//"--no-reload"
]
},
在上述的片段中,我猜想"FLASK_DEBUG"是关键.
Flask 的官方网站是这么说的:
To switch Flask to the development environment and enable debug mode, set FLASK_ENV:
$ export FLASK_ENV=development
$ flask run
(On Windows, use set instead of export.)
Using the environment variables as described above is recommended. While it is possible to set ENV and DEBUG in your config or code, this is strongly discouraged. They can ’ t be read early by the flask command, and some systems or extensions may have already configured themselves based on a previous value.
原文请参考
http://flask.pocoo.org/docs/1.0/config/