本篇博客主要记录python3.6使用flask开发
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.config['DEBUG'] = True
@app.route('/')
def index():
return "hello,world"
if __name__ == "__main__":
app.run()
4. 运行app.py
终端执行:python3 app.py
浏览器访问:http://127.0.0.1:5000/
5. url传参访问
from flask import Flask
app = Flask(__name__)
app.config['DEBUG'] = True
@app.route('/')
def index():
return "hello,world"
@app.route('/user/<name>')
def user(name):
return f"hello,{name}"
if __name__ == "__main__":
app.run()
标签:__,name,pip3,flask,study,Flask,001,app
From: https://www.cnblogs.com/liwanliangblog/p/17967252