赞
踩
from flask import Flask,request
@app.route("/req")
def req():
print(request.method) #获取访问方式 GET
print(request.url) #获取url http://127.0.0.1:5000/req?id=1&name=wl
print(request.cookies) #获取cookies {}
print(request.path) # 获取访问路径 /req
print(request.args) #获取url传过来的值 ImmutableMultiDict([('id', '1'), ('name', 'wl')])
print(request.args.get("id")) #get获取id 1
print(request.args["name"]) # 索引获取name的值 wl
print(request.args.to_dict()) # 获取到一个字典 {'id': '1', 'name': 'wl'}
return "Hello"
<!DOCTYPE html<
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。