Use the run () mode to start the Flask app, but after each code change, a reboot is required, which is inconvenient for debugging. The debug mode of flask allows the code to be loaded automatically after each modification.
There are two ways to enable debug mode for flask
1. Directly set the app's debug to True:
App.debug=true
2. Pass the debug=true as a parameter to the Run method
App.run (Debug=true)
In the first case, when we set the debug mode, the output of the console window will change accordingly.
Now visit the app's homepage:
Modify the code on the homepage:
@app. Route ("/")
def index ():
return "Index Page with Debug"
After modification, you can see the output of the console window
Then refresh the page directly:
The changes are in effect!
Debug mode is very convenient for debugging the development process, but for security exams, the production environment must not use debug mode.
Python Web Development-flask Debug mode