FlaskScript
安装pip install Flask-Script -i https://pypi.douban.com/simple
Flsak加入flask-script
- # -*- coding: utf-8 -*-
- import apps
- from apps import db
- from flask_script import Manager
- my_app = apps.create_app()
- manager = Manager(my_app)
-
- # ---------------- flask_script
- # 直接运行命令
- @manager.command
- def runflask():
- my_app.run()
- return "ok"
-
- # 启动时带参数
- # --name 是-n的全称, dest是参数的命名
- @manager.option("-n", "--name", dest="arg")
- @manager.option("-s", "--say", dest="say")
- def open_flask(arg, say):
- my_app.run(arg, say)
- return arg, say
-
-
- if __name__ == "__main__":
- # my_app.run("0.0.0.0", port=5000, debug=True)
- manager.run() # flask_script
-
-
- 运行
- python manager.py talk -n 赵丽颖 -s 漂亮
- python manager.py talk --name 赵丽颖--say 漂亮
以上是 FlaskScript 的全部内容, 来源链接: utcz.com/z/531937.html