Flask插件---flask_script与flask_migrate

颛孙国源
2023-12-01
import app
from flask_script import Manager
from flask_migrate import Migrate,MigrateCommand

my_app = app.create_app()
manager = Manager(my_app)

from app import db

Migrate(my_app,db)

manager.add_command("database",MigrateCommand)


@manager.command
def runflask():
    my_app.run()
    return "成功"

@manager.option("-n","--name",dest="name")
@manager.option("-s","--say",dest="say")
def run_flask(name,say):
    a = input("真的要启动吗?")
    if a=="y":
        if not name:
            name="127.0.0.1"
        if not say:
            say = 5000
        my_app.run(name,int(say))
    else:
        return f"{name}真{say}"



if __name__ == '__main__':
    manager.run()

# python manager.py runserver

 

posted on 2019-02-16 08:12 徐建0304 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/Treasuremy/p/10386693.html

 类似资料: