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