Visual Studio Code

vscode debug flask web app 使用本机I

2018-05-17  本文已影响5人  旭日丶丶

开始弄了半天 用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

上一篇下一篇

猜你喜欢

热点阅读