ungleich-otp/ungleichotp/otpauth/views.py
2018-11-17 18:48:12 +01:00

31 lines
864 B
Python

from django.shortcuts import render
from rest_framework import viewsets
from rest_framework.parsers import JSONParser
from otpauth.serializer import VerifySerializer
from django.http import HttpResponse, JsonResponse
import json
class VerifyViewSetV1(viewsets.ModelViewSet):
serializer_class = VerifySerializer
def get_queryset(self):
return None
class VerifyViewSet(viewsets.ViewSet):
serializer_class = VerifySerializer
def create(self, request):
data = JSONParser().parse(request)
serializer = VerifySerializer(data=data)
if serializer.is_valid():
print("is valid")
print(serializer)
#serializer.save()
return JsonResponse(serializer.data, status=201)
return JsonResponse(serializer.errors, status=400)
def get_queryset(self):
return []