The Flask (Werkzeug) debugger is really good, but it only triggers on exceptions — sometimes it could be useful for debugging behavior that isn't raising anything. In these situations you can simply raise an exception intentionally.
@app.route('/')
def index():
do_something_wrong()
raise
return 'Ohnoes'
This use of raise is actually wrong, which means it… raises an exception. ☺
If you're afraid you might accidentally leave this in the code, here's one that only enters the debugger in debug-mode:
assert app.debug == False
This snippet by Dag Odenhall can be used freely for anything you like. Consider it public domain.
Comments
Division zero abusing by Armin Ronacher on 2010-05-26 @ 15:46
My classic:
Put it in a function by Dag Odenhall on 2010-05-27 @ 02:46
Now you can trigger the debugger with
debug().Give yourself a message by Ron DuPlain on 2011-01-15 @ 22:52
The function from Dag above is great. I'll extend it slightly to add a friendly reminder message that you're seeing the debugger because you requested it.