-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunserver.py
More file actions
30 lines (28 loc) · 880 Bytes
/
runserver.py
File metadata and controls
30 lines (28 loc) · 880 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
28
29
30
#!/usr/bin/env python
import sys
import os
from cumblr import app
from cumblr.database import db, setup_database
if __name__ == '__main__':
if '--drop' in sys.argv:
with app.app_context():
db.drop_all()
db.session.commit()
print('Database tables dropped')
if '--clear' in sys.argv:
with app.app_context():
db.reflect()
db.drop_all()
db.create_all()
setup_database()
db.session.commit()
print('Database tables dropped and recreated')
if '--setup' in sys.argv:
with app.app_context():
db.create_all()
db.session.commit()
print('Database tables created')
else:
host = os.environ.get('HOST', '0.0.0.0')
port = int(os.environ.get('PORT', 5000))
app.run(host=host, port=port)