How to debug a Flask app

前端 未结 13 2481
陌清茗
陌清茗 2020-11-22 03:08

How are you meant to debug errors in Flask? Print to the console? Flash messages to the page? Or is there a more powerful option available to figure out what\'s happening

13条回答
  •  时光取名叫无心
    2020-11-22 04:03

    If you want to debug your flask app then just go to the folder where flask app is. Don't forget to activate your virtual environment and paste the lines in the console change "mainfilename" to flask main file.

    export FLASK_APP="mainfilename.py"
    export FLASK_DEBUG=1
    python -m flask run --host=0.0.0.0
    

    After you enable your debugger for flask app almost every error will be printed on the console or on the browser window. If you want to figure out what's happening, you can use simple print statements or you can also use console.log() for javascript code.

提交回复
热议问题