开始弄了半天 用vscode debug的时候无法使用本机地址, 只能自己访问, 局域网访问不了, 后来弄了半天找了半天资料, 自己终于试出来了:
launch.json里加入:
{
"name": "Python: Flask (0.11.x or later)",
"type": "python",
"request": "launch",
"stopOnEntry": false,
"pythonPath": "${config:python.pythonPath}",
"program": "${workspaceRoot}/run.py",
"module": "flask",
"cwd": "${workspaceFolder}",
"env": {
"FLASK_APP": "${workspaceFolder}/manage.py", //你的启动py
"FLASK_RUN_HOST":"0.0.0.0", //本机IP
"FLASK_RUN_PORT": 5000, //端口号
"FLASK_DEBUG": 1, //开启debug模式
},
"args": [
"run",
// "--no-debugger",
// "--no-reload"
],
"envFile": "${workspaceFolder}/.env",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
]
},
ref:
http://flask.pocoo.org/docs/1.0/cli/#setting-command-options
https://stackoverflow.com/a/41940807/2268680
网友评论