forked from apryor6/flask_api_example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanage.py
More file actions
35 lines (24 loc) · 673 Bytes
/
Copy pathmanage.py
File metadata and controls
35 lines (24 loc) · 673 Bytes
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
import os
from flask_script import Manager
from app import create_app, db
from commands.seed_command import SeedCommand
env = os.getenv('FLASK_ENV') or 'test'
print(f'Active environment: * {env} *')
app = create_app(env)
manager = Manager(app)
app.app_context().push()
manager.add_command('seed_db', SeedCommand)
@manager.command
def run():
app.run()
@manager.command
def init_db():
print('Creating all resources.')
db.create_all()
@manager.command
def drop_all():
if input('ARE YOU SURE YOU WANT TO DROP ALL TABLES? (Y/N)\n').lower() == 'y':
print('Dropping tables...')
db.drop_all()
if __name__ == '__main__':
manager.run()