码迷,mamicode.com
首页 > 其他好文 > 详细

Django接口数据处理

时间:2018-11-15 23:16:31      阅读:296      评论:0      收藏:0      [点我收藏+]

标签:span   bsp   ati   use   ret   response   utf-8   pre   password   

1get接口数据处理

# get接口数据处理
def dadaHandle_get(request):
    if request.method == GET:
        results = {}
        username = request.GET.get(username)
        mobile = request.GET.get(mobile)
        data = request.GET.get(data)
        results[user] = username
        results[mobileNum] = mobile
        results[data]= data
        results =json.dumps(results)
        return HttpResponse(results,content_type=application/json;charset=utf-8)
    else:
        return render_to_response(login.html)

 

2post接口数据处理

def dadaHandle_post(request):
    if request.method == POST:
        results = {}
        username = request.POST.get(username)
        password = request.POST.get(password)
        results[user] = username
        results[pwd] = password
        results =json.dumps(results)
        return HttpResponse(results,content_type=application/json;charset=utf-8)
    else:
        return render_to_response(login.html)

 

Django接口数据处理

标签:span   bsp   ati   use   ret   response   utf-8   pre   password   

原文地址:https://www.cnblogs.com/santiandayu/p/9966672.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!