美文网首页Visual Studio Code
vscode debug flask web app 使用本机I

vscode debug flask web app 使用本机I

作者: 旭日丶丶 | 来源:发表于2018-05-17 17:52 被阅读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

    相关文章

      网友评论

        本文标题:vscode debug flask web app 使用本机I

        本文链接:https://www.haomeiwen.com/subject/bvkidftx.html