-
Notifications
You must be signed in to change notification settings - Fork 1
/
views.py
21 lines (18 loc) · 880 Bytes
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from snippets.serializers import FLIPSerializer
class FlipView(generics.GenericAPIView):
serializer_class = FLIPSerializer
permission_classes = [permissions.IsAuthenticatedOrReadOnly,
IsOwnerOrReadOnly,
IsAuthenticated]
def post(self, request, *args, **kwargs):
serializer_class = self.get_serializer_class()
serializer = serializer_class(data=request.data, context={'request': request})
serializer.is_valid(raise_exception=True)
code = request.data['code']
from .thinker import go
categories_dict = asyncio.run(go(code))
categories = categories_dict[0],
sentences = categories_dict[1],
title = categories_dict[2]
nlp_returned = {"title" : title, "categories" : categories, "sentences" : sentences}
return Response(nlp_returned)