mirror of
https://github.com/pallets-eco/flask-debugtoolbar.git
synced 2026-01-05 21:20:12 -06:00
Add SQLAlchemy to test app
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from flask import Flask, render_template
|
||||
from flask_debugtoolbar import DebugToolbarExtension
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
|
||||
app = Flask('basic_app')
|
||||
app.debug = True
|
||||
@@ -10,8 +11,20 @@ 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()
|
||||
Reference in New Issue
Block a user