首页 > 解决方案 > VS Code Flask 调试

问题描述

在 Windows 10 上烧瓶新手。

我正在阅读基本的Flask 教程,但运行调试器的输出始终是这样的:

& 'C:\Users\User\AppData\Local\Programs\Python\Python38\python.exe' 'c:\Users\User\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy\launcher' '51698' '--' '-m' 'flask' 'run' '--no-debugger' '--no-reload' 
 * Serving Flask app "app.py"
 * Environment: development
 * Debug mode: on
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

主调试 UI 控件 Step into、Step out 和 Step over 显示为灰色。键盘快捷键也不起作用。

所有设置和配置都是默认选项,我尝试过使用虚拟环境,但没有。使用 Python 64 位 v3.85。调试配置 = Python:烧瓶。启动.json:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Flask",
            "type": "python",
            "request": "launch",
            "module": "flask",
            "env": {
                "FLASK_APP": "app.py",
                "FLASK_ENV": "development",
                "FLASK_DEBUG": "0" // Also tried with "1"
            },
            "args": [
                "run",
                "--no-debugger",
                "--no-reload"
            ],
            "jinja": true
        }
    ]
}

我错过了什么?任何帮助表示赞赏。

标签: pythonflaskvisual-studio-codevscode-debugger

解决方案


解决了:

这是工作。我必须打开浏览器到正确的页面(在本教程中为 localhost:5000/hello/),调试器才能激活。


推荐阅读