Flask: Debug Mode
Using ‘app.run(debug=True)’ to avoid excessive server restarts
Adding debug=True
parameter to app.run()
will prevent developer from having to restart server each time app.py
file is modified. As the following example shows:
if __name__ == '__main__':
app.run(debug=True)
Debug mode will return lines of status information whenever a change to app.py
is detected, as demonstrated in the example below:
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: 123-987-654
Once the app.py
file is finalized, then the if
statement can return to its original state:
if __name__ == '__main__':
app.run()