Skip to content

Instantly share code, notes, and snippets.

@yerkbn
Last active April 16, 2019 10:07
Show Gist options
  • Save yerkbn/b6b51ca099d4d72e6e59c1aade47b79b to your computer and use it in GitHub Desktop.
Save yerkbn/b6b51ca099d4d72e6e59c1aade47b79b to your computer and use it in GitHub Desktop.
from rest_framework.response import Response
from rest_framework.decorators import api_view, permission_classes
from rest_framework.permissions import AllowAny
from rest_framework.status import (
HTTP_200_OK,
HTTP_400_BAD_REQUEST,
)
from .classification_research.CNN import CNN
CNN_obj = CNN()
@api_view(['POST'])
@permission_classes((AllowAny,))
def classify(request):
try:
file = request.data['file']
except KeyError:
return Response({'file': ['no file']}, status=HTTP_400_BAD_REQUEST)
result = CNN_obj.prediction(file)
return Response(result, status=HTTP_200_OK)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment