Files
flask-debugtoolbar/test/basic_app.py
Jeff Widman 9c7db48362 Explicitly disable SQLALCHEMY_TRACK_MODIFICATIONS
This silences deprecation warnings.
Background: https://stackoverflow.com/a/33790196/770425

Note: This code can be removed once `flask_sqlalchemy` 3.0 ships, or any
release that includes
https://github.com/pallets/flask-sqlalchemy/pull/727.
2020-02-17 21:36:01 -08:00

36 lines
790 B
Python

from flask import Flask, render_template
from flask_sqlalchemy import SQLAlchemy
from flask_debugtoolbar import DebugToolbarExtension
app = Flask('basic_app')
app.debug = True
app.config['SECRET_KEY'] = 'abc123'
# TODO: This can be removed once flask_sqlalchemy 3.0 ships
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():
db.create_all()
Foo.query.filter_by(id=1).all()
return render_template('basic_app.html')
if __name__ == '__main__':
app.run()