在 VScode 调试器中更改烧瓶运行端口

Sin*_*ina 8 flask visual-studio-code vscode-settings vscode-debugger

我确实有一个在端口上运行的烧瓶应用程序,8000因为我在端口上运行了 logstash 5000

app.run(debug=True, host='0.0.0.0', port=8000)

我可以成功运行我的应用程序。但是当我使用 VScode 调试器时,它会抛出

OSError: [Errno 98] 地址已被使用

因为调试器尝试在端口上运行我的应用程序5000。我尝试编辑.vscode/launch.json"port": 8000在里面设置,configurations但错误仍然相同。我如何告诉 VScode 在另一个端口上使用调试器运行我的应用程序?

abd*_*sco 14

args密钥添加到您的调试配置并在那里设置端口:

https://code.visualstudio.com/docs/python/debugging#_set-configuration-options

{
    "name": "Python: startup.py",
    "type": "python",
    "request": "launch",
    "program": "${workspaceFolder}/startup.py",
    "args" : ["run", "--port", "8000"]
}
Run Code Online (Sandbox Code Playgroud)