Commit 062a1d5a by qinjiaxin

去掉没用的包

parent b52bf9f2
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.http import JsonResponse, HttpResponseNotAllowed, HttpResponse from django.http import JsonResponse, HttpResponseNotAllowed, HttpResponse
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
from rest_framework.parsers import JSONParser
from rest_framework import status
import json import json
import remark16 import remark16
def add_args(a, b): def add_args(a, b):
return a+b return a+b
# @csrf_exempt
# def run_job(request):
# # 判断请求头是否为json
# if request.content_type != 'application/json':
# # 如果不是的话,返回405
# return HttpResponse('only support json data', status=status.HTTP_415_UNSUPPORTED_MEDIA_TYPE)
# dic = {}
# # 判断是否为post 请求
# if request.method == 'POST':
#
# # 解析请求的json格式入参
# # data = JSONParser().parse(request)
# a = request.POST.get('a', 0)
# b = request.POST.get('b', 0)
# if a and b:
# res = add_args(a, b)
# dic['number'] = res
# dic = json.dumps(dic)
# # return JsonResponse(dic, status=status.HTTP_200_OK)
# return HttpResponse(dic)
# else:
# return HttpResponse("输入错误")
# # except Exception as why:
# # print(why.args)
# else:
# # content = {'msg': 'SUCCESS'}
# # print(data)
# # 返回自定义请求内容content,200状态码
# return HttpResponse("请求方法错误")
# # 如果不是post 请求返回不支持的请求方法
# #return HttpResponseNotAllowed(permitted_methods=['POST'])
@csrf_exempt @csrf_exempt
def run_job(request): def run_job(request):
if request.method == 'POST': # 当提交表单时 if request.method == 'POST': # 当提交表单时
...@@ -47,6 +15,5 @@ def run_job(request): ...@@ -47,6 +15,5 @@ def run_job(request):
sentence = [s['test_x']] sentence = [s['test_x']]
result = remark16.main(sentence) result = remark16.main(sentence)
data = {'lables':result} data = {'lables':result}
# return HttpResponse(json.dumps(remark16.main(sentence)))
return JsonResponse(data,safe = False) return JsonResponse(data,safe = False)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment