forked from erynet/IMHMv2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
37 lines (24 loc) · 801 Bytes
/
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
#!/imhm/penv/bin/python
# -*- coding:utf-8 -*-
__author__ = 'ery'
from flask_script import Manager, Server, Shell
from flask_migrate import Migrate, MigrateCommand
from werkzeug.contrib.fixers import ProxyFix
from imhm import create_app
from imhm.models import *
from imhm.tools import Base, DB
app = create_app()
app.wsgi_app = ProxyFix(app.wsgi_app)
manager = Manager(app)
migrate = Migrate(app, Base)
server = Server(host="0.0.0.0")
def make_shell_context():
return dict(app=app, db=DB.get_session(),)
manager.add_command("shell", Shell(make_context=make_shell_context))
manager.add_command("db", MigrateCommand)
manager.add_command("runserver", server)
@manager.command
def initdb():
Base.metadata.create_all(bind=DB.get_engine())
if __name__ == "__main__":
manager.run()