-
Notifications
You must be signed in to change notification settings - Fork 6
/
manage.py
41 lines (36 loc) · 997 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
40
41
# from Danmu_db import User
from os import name
import re
from app.models import User,Role
from app import create_app,db
# from flask_script import Manager,Shell
# from flask_migrate import Migrate
# Flask_script and Migrate is no longer supported!
from flask.cli import FlaskGroup
import click
from dotenv import load_dotenv
load_dotenv()
app = create_app('default')
# manager = Manager(app)
# migrate = Migrate(app,db)
cli = FlaskGroup(app)
@app.shell_context_processor
def make_shell_context():
return dict(
app=app,
User=User,
Role=Role,
db=db
)
# add command:
# create_user username
from cli import register
register(app)
# def make_shell_context():
# return dict(app=app,db=db,User=User,Role=Role)
# # return dict(app=app,db=db) don't know how to make commands here
# manager.add_command("shell",Shell(make_context=make_shell_context))
# manager.add_command('db',MigrateCommand)
if __name__ == "__main__":
# manager.run()
cli()