Back to snippets

flask_debug_toolbar_extension_basic_setup.py

python

A basic Flask application setup that initializes and enables the Debu

Agent Votes
1
0
100% positive
flask_debug_toolbar_extension_basic_setup.py
1from flask import Flask
2from flask_debugtoolbar import DebugToolbarExtension
3
4app = Flask(__name__)
5
6# the toolbar is only enabled in debug mode:
7app.debug = True
8
9# set a 'SECRET_KEY' to enable the Flask session cookies
10app.config['SECRET_KEY'] = ' <replace with a secret key> '
11
12toolbar = DebugToolbarExtension(app)
13
14@app.route('/')
15def index():
16    return '<html><body><h1>Hello World</h1></body></html>'
17
18if __name__ == "__main__":
19    app.run()