diff --git a/backend/tasks/urls.py b/backend/tasks/urls.py index d4f229e6f..1df41e6cf 100644 --- a/backend/tasks/urls.py +++ b/backend/tasks/urls.py @@ -6,6 +6,7 @@ AnnotationViewSet, PredictionViewSet, get_celery_tasks, + TransliterationAPIView, ) router = routers.DefaultRouter() @@ -15,4 +16,9 @@ urlpatterns = [ path("get_celery_tasks/", get_celery_tasks), + path( + "xlit-api/generic/transliteration//", + TransliterationAPIView.as_view(), + name="transliteration-api", + ), ] + router.urls diff --git a/backend/tasks/views.py b/backend/tasks/views.py index 43ebf9339..200fc1250 100644 --- a/backend/tasks/views.py +++ b/backend/tasks/views.py @@ -53,6 +53,7 @@ import sacrebleu from utils.date_time_conversions import utc_to_ist +from rest_framework.views import APIView # Create your views here. @@ -2642,3 +2643,16 @@ def get_celery_tasks(request): page_size = int(request.GET.get("page_size", 10)) data = paginate_queryset(filtered_tasks, page_number, page_size) return JsonResponse(data["results"], safe=False) + + +class TransliterationAPIView(APIView): + permission_classes = [IsAuthenticated] + + 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")}, + ) + + transliteration_output = response_transliteration.json() + return Response(transliteration_output, status=status.HTTP_200_OK)