Flask Debug Toolbar

0.16.0 · active · verified Sat Apr 11

Flask-DebugToolbar is a Flask extension that provides a customizable toolbar overlay for debugging web applications. It's an active project within the Pallets Community Ecosystem, currently at version 0.16.0, and releases updates periodically to maintain compatibility with Flask and Python.

Warnings

Install

Imports

Quickstart

To enable the Flask Debug Toolbar, initialize it with your Flask application. Crucially, set `app.debug = True` and configure a `SECRET_KEY` in `app.config`. The toolbar is automatically injected into HTML responses when debug mode is active. For full functionality, ensure your responses contain a `<body>` tag. Using `render_template` is recommended.

from flask import Flask, render_template
from flask_debugtoolbar import DebugToolbarExtension
import os

app = Flask(__name__)
app.debug = True  # Enable debug mode
app.config['SECRET_KEY'] = os.environ.get('FLASK_SECRET_KEY', 'a_very_secret_key_for_dev')

# Optional: Configure toolbar settings
# app.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = False

toolbar = DebugToolbarExtension(app)

@app.route('/')
def index():
    return '<body><h1>Hello, Flask!</h1></body>'

@app.route('/hello/<name>')
def hello(name):
    return render_template('hello.html', name=name) # Ensure templates are in 'templates/' folder

# Example of running the app
# if __name__ == '__main__':
#     # You would typically run with 'flask run --debug' or a WSGI server
#     # For this quickstart, ensure FLASK_APP is set to your app file (e.g., 'app.py')
#     # and then run 'flask run --debug'
#     pass

view raw JSON →