命令启动flask以及自定义命令
通过命令启动flask,以及自定义命令
"""
自定义命令,通过命令启动flask
安装:pip install flask-script
"""
from flask_script import Manager
from flask import Flask
app = Flask(__name__)
manage = Manager(app)
@app.route('/')
def index():
return 'ok'
# 自定义命令
@manage.command
def cd(arg, t):
# 命令的名字的和函数名一致,有参数也必须传参数
print(arg, t)
@manage.option('-n', '--name', dest='name')
@manage.option('-u', '--url', dest='url') # dest的名字必须个你自定义命令中的参数名一致
def cmd(name, url):
print(name, url)
if __name__ == '__main__':
manage.run()
Only you can control your future
You're not alone. You still have family,peopel who care for you and want to save you.