import click
from flask import Flask
app = Flask(__name__)
app.debug = True
@app.route('/')
def hello_world():
return 'Hello World!1'
@app.cli.command()
def hello():
click.echo('Hello')
@app.cli.command('users')
@click.argument('name')
def user(name):
"""这是一个自定义的命令"""
click.echo(name)
if __name__ == '__main__':
app.run(debug=True)
显示效果
Commands:
hello
routes Show the routes for the app.
run Runs a development server.
shell Runs a shell in the app context.
users 这是一个自定义的命令
使用方法
PS E:\flask\pylyccms> flask users 小明
小明