Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Building Web Applications with Flask

You're reading from   Building Web Applications with Flask Use Python and Flask to build amazing web applications, just the way you want them!

Arrow left icon
Product type Paperback
Published in Jun 2015
Publisher
ISBN-13 9781784396152
Length 160 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

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
from flask import Flask

app = Flask(__name__)

@app.route("/")
def index_view(arg=None):
    import pdb; pdb.set_trace()  # @TODO remove me before commit
    return 'Arg is %s' % arg


if __name__ == '__main__':
    app.debug = True
    app...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image