Flask 扩展: Flask-Script

xiaoxiao2021-02-27  257

Flask-Script 安装使用

Flask-Script

Flask-Script 是一个 Flask 扩展, 为 Flask 程序添加了一个命令行解析器。

安装

pip install flask-script

使用

from flask-script import Manager manager = Manager(app) #... if __name__=='__main__': manager.run() (flask) $ python hello.py usage: hello.py [-?] {shell,runserver} ... positional arguments: {shell,runserver} shell Runs a Python shell inside Flask application context. runserver Runs the Flask development server i.e. app.run() optional arguments: -?, --help show this help message and exit

运行Web服务器:

(flask) $ python hello.py runserver * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
转载请注明原文地址: https://www.6miu.com/read-9658.html

最新回复(0)