forked from niqzart/ffs-test-task
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
27 lines (18 loc) · 631 Bytes
/
app.py
File metadata and controls
27 lines (18 loc) · 631 Bytes
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
from common import db, db_url, TEST_USERNAME, TEST_PASSWORD
from main import app, socketio
def init_users():
from common.users_db import User
if User.find_by_username(TEST_USERNAME) is None:
User.create(TEST_USERNAME, TEST_PASSWORD)
with app.app_context():
if db_url == "sqlite:///../app.db":
db.drop_all()
db.create_all()
if db_url == "sqlite:///../test.db":
db.create_all()
init_users()
db.session.commit()
app.after_request(db.with_autocommit)
socketio.after_event(db.with_autocommit)
if __name__ == "__main__": # test only
socketio.run(app=app, debug=True)