Debugging, DebugToolbar, and happiness

When running your Flask project in debug mode (app.debug = True), whenever Flask detects that your code has changed it will restart your application. If the given change breaks your application, Flask will display an error message in the console that is actually very simple to analyze. You start reading from the bottom up until you find the first line that mentions a file you wrote; that's where the error was generated. Now, read from the top down until you find a line telling you exactly what the error was. If this approach is not sufficient and if you need to read a variable value—for example, to better understand what is going on—you may use pdb, the standard Python debugging library, like this:

# coding:utf-8 ...

Get Building Web Applications with Flask now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.