Debug Mode (Flask)
Flask's debug mode enables the interactive in-browser debugger and the auto-reloader during development. When an exception occurs you get a detailed traceback and a console, and code changes restart the server automatically.
Flask
Debug mode is a development convenience with two big features: the reloader restarts the server whenever you save a file, and the debugger replaces the generic 500 page with a full traceback plus an interactive Python console at the point of failure.
You enable it with app.run(debug=True) or by setting the FLASK_DEBUG=1 environment variable. It must never be on in production: the interactive console lets anyone who triggers an error execute arbitrary code on your server, a critical security hole.
Debug mode is independent of the LOG level and of app.config settings; for production you instead run behind a real WSGI server like gunicorn with debug off and proper error logging.
Syntax
app.run(debug=True) # development onlyExamples
Python — Never enable debug in production.
if __name__ == "__main__":
app.run(debug=True) # auto-reload + interactive debugger