mirror of
https://github.com/pallets-eco/flask-debugtoolbar.git
synced 2026-05-01 13:59:36 -05:00
e6ae9d0288
1. Update the test app If I understand correctly, the debug toolbar will only be enabled if `app.debug` is `True`. So I added the `DEBUG=True` to the test app. Related code: https://github.com/pallets-eco/flask-debugtoolbar/blob/2b8bf9cc449a95f442b99dfdfb6147fa1ae2230a/src/flask_debugtoolbar/__init__.py#L114 2. Update the `src/flask_debugtoolbar/__init__.py` Fix the two if statements to prevent the following errors: ``` > if 'gzip' in response.headers.get('Content-Encoding'): E TypeError: argument of type 'NoneType' is not iterable ``` Since the `response.headers.get('Content-Encoding')` could be None. With this PR, all the tests will be passed. The failed style checker will be fixed in #219
36 lines
935 B
Python
36 lines
935 B
Python
from flask import Flask, render_template
|
|
from flask_sqlalchemy import SQLAlchemy
|
|
|
|
from flask_debugtoolbar import DebugToolbarExtension
|
|
|
|
app = Flask('basic_app')
|
|
app.config['DEBUG'] = True
|
|
app.config['SECRET_KEY'] = 'abc123'
|
|
app.config['SQLALCHEMY_RECORD_QUERIES'] = True
|
|
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'
|
|
# This is no longer needed for Flask-SQLAlchemy 3.0+,
|
|
# if you're using 2.X you'll want to define this:
|
|
# app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
|
|
|
# make sure these are printable in the config panel
|
|
app.config['BYTES_VALUE'] = b'\x00'
|
|
app.config['UNICODE_VALUE'] = u'\uffff'
|
|
|
|
toolbar = DebugToolbarExtension(app)
|
|
db = SQLAlchemy(app)
|
|
|
|
|
|
class Foo(db.Model):
|
|
__tablename__ = 'foo'
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
|
|
@app.route('/')
|
|
def index():
|
|
Foo.query.filter_by(id=1).all()
|
|
return render_template('basic_app.html')
|
|
|
|
|
|
with app.app_context():
|
|
db.create_all()
|