json
发送数据
接收数据
def json(request):
body = request.body
#print(body)
body_str = body.decode()
print(body_str)
print(type(body_str))
import json
body_dict = json.loads(body_str)
print(
body_dict
)
return HttpResponse('json')
请求代码
Session
Session 保存到服务器,cookie到本地
类视图的定义
class 类视图名字(View):
def get(self,request):
return HttpResponse('xxx')
def http_method_lower(self,request):
return HttpResponse('xxx')
- 继承自View
MRO
调用顺序
标签:HttpRequest,web,对象,request,body,json,str,print,HttpResponse From: https://www.cnblogs.com/jtailong/p/18408634