
The debug mode
The Flask application run method has a debug option, which, when used, runs it in the debug mode:
app.run(debug=True)
The debug mode is a special mode, where the built-in debugger takes precedence on any error, and allows you to interact with the app from a browser:

The console in the web-debugger will let you interact with the current app, and inspect variables or execute any Python code that is in the current execution frame.
Flask will even let you configure a third-party debugger. JetBrains's PyCharm (https://www.jetbrains.com/pycharm), for example, is a commercial IDE for Python, which offers a powerful visual debugger that can be set up to run with Flask.
The plain old pdb module is also a good option when you are tracking down a problem by inserting a pdb.set_trace() call in your code.