From 97a77192c71a31b499b828ec24f4084625df79d7 Mon Sep 17 00:00:00 2001 From: kartikvirendrar Date: Thu, 10 Oct 2024 11:26:43 +0530 Subject: [PATCH 1/2] minor changes for xlit endpoint --- backend/backend/urls.py | 2 +- backend/video/urls.py | 2 +- backend/video/views.py | 24 ++++++++---------------- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/backend/backend/urls.py b/backend/backend/urls.py index 107481ed..7db6798b 100644 --- a/backend/backend/urls.py +++ b/backend/backend/urls.py @@ -74,7 +74,7 @@ def get_schema(self, request=None, public=False): path("voiceover/", include("voiceover.urls")), path("youtube/", include("youtube.urls")), path( - "api/generic/transliteration///", + "xlit-api/generic/transliteration//", TransliterationAPIView.as_view(), name="transliteration-api", ), diff --git a/backend/video/urls.py b/backend/video/urls.py index 32789a86..c9e82354 100644 --- a/backend/video/urls.py +++ b/backend/video/urls.py @@ -6,7 +6,7 @@ urlpatterns = [ path("", views.get_video, name="get_video"), path( - "api/generic/transliteration///", + "xlit-api/generic/transliteration//", TransliterationAPIView.as_view(), name="transliteration-api", ), diff --git a/backend/video/views.py b/backend/video/views.py index b2d2c0e6..69c80a59 100644 --- a/backend/video/views.py +++ b/backend/video/views.py @@ -37,6 +37,7 @@ from collections import Counter from rest_framework.views import APIView import config +from rest_framework.permissions import IsAuthenticated accepted_languages = [ "as", @@ -96,25 +97,16 @@ class TransliterationAPIView(APIView): + permission_classes = [IsAuthenticated] + def get(self, request, target_language, data, *args, **kwargs): - json_data = { - "input": [{"source": data}], - "config": { - "language": { - "sourceLanguage": "en", - "targetLanguage": target_language, - }, - "isSentence": False, - "numSuggestions": 5, - }, - } - logging.info("Calling Transliteration API") - response_transliteration = requests.post( - config.transliteration_url, - headers={"authorization": config.dhruva_key}, - json=json_data, + response_transliteration = requests.get( + os.getenv("TRANSLITERATION_URL") + target_language + "/" + data, + # headers={"Authorization": "Bearer " + os.getenv("TRANSLITERATION_KEY")}, ) + print(response_transliteration) + transliteration_output = response_transliteration.json() return Response(transliteration_output, status=status.HTTP_200_OK) From 24ac72e1951b85e980681ebbba5c3a36188c5226 Mon Sep 17 00:00:00 2001 From: kartikvirendrar Date: Thu, 10 Oct 2024 11:27:08 +0530 Subject: [PATCH 2/2] minor changes for xlit endpoint --- backend/video/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/video/views.py b/backend/video/views.py index 69c80a59..8cbeaa1c 100644 --- a/backend/video/views.py +++ b/backend/video/views.py @@ -102,7 +102,7 @@ class TransliterationAPIView(APIView): def get(self, request, target_language, data, *args, **kwargs): response_transliteration = requests.get( os.getenv("TRANSLITERATION_URL") + target_language + "/" + data, - # headers={"Authorization": "Bearer " + os.getenv("TRANSLITERATION_KEY")}, + headers={"Authorization": "Bearer " + os.getenv("TRANSLITERATION_KEY")}, ) print(response_transliteration)