1.pip3配置国内源(阿里云)
pip3 config set global.index-url https://mirrors.aliyun.com/pypi/simple
查看:pip3 config list
2.安装flask
环境
pip3 install flask
3.创建app.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return "hello,world"
if __name__ == "__main__":
app.run('0.0.0.0', debug=True)
4.运行app.py
执行:python3 app.py
5.浏览器访问:http://127.0.0.1:5000
6.使用url传参。通过:http://127.0.0.1:5000/user/xxx 访问
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return "hello,world"
@app.route('/user/<name>')
def user(name):
return f"hello,{name}"
if __name__ == "__main__":
app.run('0.0.0.0', debug=True)
标签:__,name,pip3,flask,0.0,app,学习,001
From: https://www.cnblogs.com/liwanliangblog/p/17966252