一、#pip install flask_script 安裝flask_script包 python
Flask-Script 是一個 Flask 擴展,爲 Flask 程序添加了一個命令行解析器。Flask-Script 自帶 了一組經常使用選項,並且還支持自定義命令。 flask
二、在源代碼中 import Manager ,代碼以下:app
from flask import Flask from flask.ext.script import Manager app = Flask(__name__) manager = Manager(app) @app.route('/') def index(): return '<h1>Hello World!</h1>' @app.route('/user/<name>') def user(name): return '<h1>Hello, %s!</h1>' % name if __name__ == '__main__': manager.run()
保存爲 hello.pyui
三、執行 python hello.py runserver -?,結果以下this
usage: flask02c.py runserver [-?] [-h HOST] [-p PORT] [--threaded]spa
[--processes PROCESSES] [--passthrough-errors]命令行
[-d] [-D] [-r] [-R]debug
Runs the Flask development server i.e. app.run()code
optional arguments:server
-?, --help show this help message and exit
-h HOST, --host HOST
-p PORT, --port PORT
--threaded
--processes PROCESSES
--passthrough-errors
-d, --debug enable the Werkzeug debugger (DO NOT use in production
code)
-D, --no-debug disable the Werkzeug debugger
-r, --reload monitor Python files for changes (not 100{'const':
True, 'help': 'monitor Python files for changes (not
100% safe for production use)', 'option_strings':
['-r', '--reload'], 'dest': 'use_reloader',
'required': False, 'nargs': 0, 'choices': None,
'default': None, 'prog': 'flask02c.py runserver',
'container': <argparse._ArgumentGroup object at
0x10fe85190>, 'type': None, 'metavar': None}afe for
production use)
-R, --no-reload do not monitor Python files for changes
就能夠進行相關主機與端口的指定。