-
Notifications
You must be signed in to change notification settings - Fork 0
/
manager.py
54 lines (38 loc) · 1.24 KB
/
manager.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
49
50
51
52
53
54
# -*- coding: utf-8 -*-
import os
from flask_script import Manager, Server
from setuptools import find_packages
from stalls.app import create_app
from stalls.extensions import db
app_root = os.path.dirname(os.path.realpath(__name__))
application = create_app('Applet-Poll')
server = Server(host='0.0.0.0', port=5000)
manager = Manager(application)
manager.add_command("runserver", server)
def _import_models():
packages = find_packages('./stalls/modules')
for each in packages:
guess_module_name = 'stalls.modules.%s.models' % each
try:
__import__(guess_module_name, globals(), locals())
print('Find model:', guess_module_name)
except ImportError:
pass
@manager.option('-p', dest='port', help='Port to host', default=13800)
def run(port):
"""Run app at 0.0.0.0"""
application.run(host='0.0.0.0', port=port, debug=True)
@manager.command
def syncdb():
with application.test_request_context():
_import_models()
db.create_all()
db.session.commit()
print('Database Created')
@manager.command
def dropdb():
with application.test_request_context():
db.drop_all()
print('Database Dropped')
if __name__ == '__main__':
manager.run()