-
-
Notifications
You must be signed in to change notification settings - Fork 70
/
bootstrap_table.py
29 lines (21 loc) · 762 Bytes
/
bootstrap_table.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from flask import Flask, render_template
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(64), index=True)
age = db.Column(db.Integer, index=True)
address = db.Column(db.String(256))
phone = db.Column(db.String(20))
email = db.Column(db.String(120), index=True)
db.create_all()
@app.route('/')
def index():
users = User.query
return render_template('bootstrap_table.html', title='Bootstrap Table',
users=users)
if __name__ == '__main__':
app.run()