コード例 #1
0
def prediccion(request):
    if request.method == 'POST':
        data = JSONParser().parse(request)
        series = Serie.objects.all()
        serializer = SerieSerializer(series, many=True)
        markov = markovgen.Markov()
        for x in serializer.data:
            markov.addText(x["texto"])
        if(data["texto"] in markov.cachee):
            return JSONResponse(markov.cachee[data["texto"]])
        else:
            return HttpResponse(status=404)
コード例 #2
0
def serie_detail(request, pk):
#    try:
#        serie = Serie.objects.get(pk=pk)
#    except Serie.DoesNotExist:
#        return HttpResponse(status=404)

    if request.method == 'GET':
        series = Serie.objects.all()
        serializer = SerieSerializer(series, many=True)
        markov = markovgen.Markov()
        for x in serializer.data:
            markov.addText(x["texto"])
        return JSONResponse(markov.cachee[pk])
コード例 #3
0
def prediccion_lista(request):
    if request.method == 'POST':
        data = JSONParser().parse(request)

        serializer = SerieSerializer(data=data)
        if serializer.is_valid():
            serializer.save()

        series = Serie.objects.all()
        serializer = SerieSerializer(series, many=True)
        markov = markovgen.Markov()

        for x in serializer.data:
            markov.addText(x["texto"])
        return JSONResponse(markov.cachee)

    if request.method == 'GET':
        series = Serie.objects.all()
        serializer = SerieSerializer(series, many=True)
        markov = markovgen.Markov()

        for x in serializer.data:
            markov.addText(x["texto"])
        return JSONResponse(markov.cachee)
コード例 #4
0
def serie_list(request):
    if request.method == 'GET':
        series = Serie.objects.all()
        serializer = SerieSerializer(series, many=True)
        markov = markovgen.Markov()
        for x in serializer.data:
            markov.addText(x["texto"])

        return JSONResponse(markov.cachee)

    elif request.method == 'POST':

        data = JSONParser().parse(request)
        serializer = SerieSerializer(data=data)
        if serializer.is_valid():
            serializer.save()
            return JSONResponse({"rest":"ok"}, status=201)
        return JSONResponse(serializer.errors, status=400)