forked from YKPS-FooBar/swim4love
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.py
48 lines (35 loc) · 1.39 KB
/
run.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import argparse
import sys
import config
if __name__ == '__main__':
# Parse config
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--host',
help='host address to run Flask',
default='localhost')
parser.add_argument('--port',
help='port to run Flask',
type=int,
default=80)
parser.add_argument('--environment',
help='environment for Flask',
choices=['development', 'production'],
default='production')
parser.add_argument('--database',
help='database URI for SQLAlchemy',
default='sqlite:///swim4love.db')
parser.add_argument('--clean',
help='remove all data from the database',
action='store_true')
args = parser.parse_args()
if args.environment == 'development':
config.app_config = config.DevelopmentConfig
config.app_config.SQLALCHEMY_DATABASE_URI = args.database
from swim4love import app, socketio
if args.clean:
from swim4love import db
with app.app_context():
db.drop_all()
sys.exit(0)
# Initialize app
socketio.run(app, host=args.host, port=args.port)