之前写回调地址做的笔记
from django.shortcuts import HttpResponse from django.views.decorators.csrf import csrf_exempt # Create your views here. import logging logging.basicConfig(level=logging.INFO) logger = logging.getLogger() msg_success = {"result": 1, "success": 1} @csrf_exempt # 装饰器的作用是取消不需要禁跨站请求 def imagcallback(request): request.encoding = "utf-8" if request.POST: logger.info("================================================================") logger.info("a: %s" % request.POST.dict()) # request.POST和request.GET都是QueryDict()的实例,可以用过request.POST["key"]获取值; # 但是,query dict 类型的数据并不是字段,这里直接调用该对象的方法,转化为dict类型,方便后面操作 logger.info("================================================================") return HttpResponse(str(msg_success))