def-APIView 响应 和 接收

其他:  https://www.cnblogs.com/kaibindirver/p/16733128.html

 

from rest_framework.views import APIView


print('获取请求头: ', request.META.get("HTTP_AUTHORIZATION"))  #AUTHORIZATION为请求头字段
print(request.data)  #直接可以接收前端传过来json 或者表单数据  返回{"name":123}
print(request.data.get("name"))
'''获取查询参数'''
print(request.query_params)    #/?aa=111
print(request.query_params.get("aa"))

设置cookie

response = Response()
response.set_cookie(key='token', value="1231")
return response

获取ccookie

request.COOKIES

 

posted @ 2022-10-18 13:46  凯宾斯基  阅读(11)  评论(0编辑  收藏  举报