V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
duzhonglin
V2EX  ›  Flask

Flask 1.0.2

  •  
  •   duzhonglin · Oct 24, 2018 · 3283 views
    This topic created in 2746 days ago, the information mentioned may be changed or developed.

    Flask 1.0.2 在哪里设置调试模式呢?那位大神晓得呢?网上的方法试了很多种都不行,我是在 win10 操作系统。谢谢

    6 replies    2018-10-25 10:42:54 +08:00
    saulshao
        1
    saulshao  
       Oct 25, 2018
    这是 Visual studio code 中 Launch.JSON 文件的配置片段:
    {
    "name": "Python: Flask (0.11.x or later)",
    "type": "python",
    "request": "launch",
    "module": "flask",
    "env": {
    //"FLASK_APP": "${workspaceFolder}/microblog.py"
    "FLASK_APP": "microblog.py",
    "FLASK_DEBUG": "1"
    },
    "args": [
    "run",
    //"--no-debugger",
    //"--no-reload"
    ]
    },
    在上述的片段中,我猜想"FLASK_DEBUG"是关键.
    Flask 的官方网站是这么说的:
    To switch Flask to the development environment and enable debug mode, set FLASK_ENV:

    $ export FLASK_ENV=development
    $ flask run
    (On Windows, use set instead of export.)

    Using the environment variables as described above is recommended. While it is possible to set ENV and DEBUG in your config or code, this is strongly discouraged. They can ’ t be read early by the flask command, and some systems or extensions may have already configured themselves based on a previous value.

    原文请参考 http://flask.pocoo.org/docs/1.0/config/
    duzhonglin
        2
    duzhonglin  
    OP
       Oct 25, 2018
    非常感谢,官网这个我也设置了没有效果的,我是以管理员的身份打开 Power shell, set FLASK_ENV=development。这样也没有效果的
    alphadog619
        3
    alphadog619  
       Oct 25, 2018
    1、app.run(debug=True)
    2、新建 config.py DEBUG = True,调用 config.py
    app.config.from_object(config)
    vipppppp
        4
    vipppppp  
       Oct 25, 2018
    我都是直接用 pycharm 以及 app.run()方式进行调试的
    duzhonglin
        5
    duzhonglin  
    OP
       Oct 25, 2018
    @vipppppp 我是用的 vscode
    duzhonglin
        6
    duzhonglin  
    OP
       Oct 25, 2018
    @alphadog619 谢谢,我晚上回去试试
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2458 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 02:40 · PVG 10:40 · LAX 19:40 · JFK 22:40
    ♥ Do have faith in what you're doing.