-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
33 lines (22 loc) · 780 Bytes
/
app.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
30
31
32
33
from flask import Flask
from flask_admin import Admin
from models import db, Student
from commands import create_database
app = Flask(__name__)
# Create dummy secrey key so we can use sessions
app.config['SECRET_KEY'] = '123456790'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
# Create in-memory database
app.config['DATABASE_FILE'] = 'sample_db.sqlite'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + app.config['DATABASE_FILE']
db.init_app(app)
app.cli.add_command(create_database)
# Flask views
@app.route('/')
def index():
return '<a href="/admin/">Click me to get to Admin!</a>'
from views import StudentView
admin = Admin(app, template_mode="bootstrap3")
admin.add_view(StudentView(Student, db.session))
if __name__ == '__main__':
app.run()