在django里如何设置响应头的头信息

1.将响应信息转化为json格式,使用response = json.dumps(response)或者response = JsonResponse(respnse)

2.设置响应头 

response["Access-Control-Allow-Origin"] = "http://192.168.10.101:8080"
response["Access-Control-Allow-Credentials"] = "true"
response["Access-Control-Allow-Methods"] = "GET,POST"
response["Access-Control-Allow-Headers"] = "Origin,Content-Type,Cookie,Accept,Token"

reutrn response
posted @ 2018-09-30 11:45  是张不是章啊  阅读(5737)  评论(1编辑  收藏  举报