1.规则
2.路由的变量规则:
string (缺省值) 接受任何不包含斜杠的文本 *
int 接受正整数 *
float 接受正浮点数
path 类似 string ,但可以包含斜杠
uuid 接受 UUID 字符串
@app.route('/getcity/<key>') # key就是一个变量名,默认是字符串类型的
def get_city(key): # 参数是必须添加的
print(type(key))
return data.get(key)
2.示例
# 示例一
@app.route('/getcity/<int:pid>') # key就是一个变量名,默认是字符串类型的
def get_city(pid): # 参数是必须添加的
print(type(pid))
return 'xx'
# 示例二,多个变量
@app.route('/getcity/<str:username>/<int:pid>') # key就是一个变量名,默认是字符串类型的
def get_city(username,pid): # 参数是必须添加的
print(type(username))
return 'xx'