flask

hello flask

安装和运行一个最简单的flask程序

环境

使用虚拟环境

$ mkdir flask
$ cd flask
$ python3 -m venv venv # 创建虚拟环境
$ . venv/bin/activate # 使用虚拟环境

安装环境

pip install Flask

安装环境

hello flask

vim hello.py

hello.py

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
return "Hello Flask!"

运行

FLASK_APP=hello.py flask run

运行

浏览器输入:http://127.0.0.1:5000/
显示:

Hello Flask!

Leave a Reply

Your email address will not be published. Required fields are marked *