from flask import Flask
app=Flask(__name__)
@app.route('/user/<int:id>')
def index(id):
if id == 1:
return 'wangyi1'
if id == 2:
return 'wangyi2'
if id == 3:
return 'wangyi3'
return "aaaa"
#参考链接:https://codingdict.com/article/4867
@app.route('/hello/<name>')
def hello_name(name):
return 'Hello %s!' % name
# 传递一个字符串 参考链接: https://blog.youkuaiyun.com/qq_33962481/article/details/113760828
@app.route('/user/<username>')
def show_user_profile(username):
# 定义一个字典
city = {'a': '北京', 'b': '上海', 'c': '广东'}
# 返回一个字典的value
r
flask路由-变量规则
于 2022-02-01 23:39:07 首次发布