/
manage.py
68 lines (55 loc) · 2.37 KB
/
manage.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!flask/bin/python
import os
from app import create_app, db
from flask.ext.script import Server, Manager, Shell
from config import setup_console, isIterable #, SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO
from sqlalchemy import func, asc, desc, and_, or_
from app.models import (
Pagination, User, Photo, Settings, Subdivision, Privileges, ExchangeRate,
admin_view_users, get_users, get_users_dict, print_users, drop_table, show_tables, print_tables, show_all,
gen_subdivisions, get_subdivisions, print_subdivisions,
app_roles, get_app_roles
)
app = create_app(os.getenv('APP_CONFIG') or 'production')
manager = Manager(app)
#setup_console()
def make_shell_context():
return dict(
app=app, db=db,
Pagination=Pagination, func=func, asc=asc, desc=desc, and_=and_, or_=or_,
User=User, Photo=Photo, Settings=Settings, Subdivision=Subdivision, Privileges=Privileges, ExchangeRate=ExchangeRate,
admin_view_users=admin_view_users, get_users=get_users, get_users_dict=get_users_dict, print_users=print_users,
drop_table=drop_table, show_tables=show_tables, print_tables=print_tables, show_all=show_all,
gen_subdivisions=gen_subdivisions, get_subdivisions=get_subdivisions, print_subdivisions=print_subdivisions,
app_roles=app_roles, get_app_roles=get_app_roles,
isIterable=isIterable,
)
manager.add_command("shell", Shell(make_context=make_shell_context))
manager.add_command("start", Server(host='0.0.0.0', port=5000))
@manager.command
def test(coverage=False):
"""Run the unit tests."""
pass
@manager.command
def profile(length=25, profile_dir=None):
"""Start the application under the code profiler."""
#from werkzeug.contrib.profiler import ProfilerMiddleware
#app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[length], profile_dir=profile_dir)
#app.run()
pass
@manager.command
def deploy():
"""Run deployment tasks."""
#from flask.ext.migrate import upgrade
# migrate database to latest revision
#upgrade()
pass
@manager.command
def start():
"""Run server."""
#ssl_context = 'adhoc'
ssl_context = ('secure/ssl.crt', 'secure/ssl.key')
app.run(host='0.0.0.0', port=5000, debug=True, ssl_context=ssl_context)
#app.run(host='0.0.0.0', port=5000, debug=True)
if __name__ == '__main__':
manager.run()