-
Notifications
You must be signed in to change notification settings - Fork 2
/
manage.py
39 lines (28 loc) · 805 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
38
39
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
from api import create_app
from api.models import db
# sets up the app
app = create_app()
manager = Manager(app)
migrate = Migrate(app, db)
# adds the python manage.py db init, db migrate, db upgrade commands
manager.add_command("db", MigrateCommand)
@manager.command
def runserver():
app.run(debug=True, host="0.0.0.0", port=5000)
@manager.command
def runworker():
app.run(debug=False)
@manager.command
def recreate_db():
"""
Recreates a database. This should only be used once
when there's a new database instance. This shouldn't be
used when you migrate your database.
"""
db.drop_all()
db.create_all()
db.session.commit()
if __name__ == "__main__":
manager.run()