Flask 1.0.2 - V2EX
duzhonglin
V2EX    Flask

Flask 1.0.2

  •  
  •   duzhonglin Oct 24, 2018 3351 views
    This topic created in 2771 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     1040 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 52ms UTC 22:43 PVG 06:43 LAX 15:43 JFK 18:43
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86