diff --git a/backend/tasks/urls.py b/backend/tasks/urls.py index ceabbf4c7..1e6cc3999 100644 --- a/backend/tasks/urls.py +++ b/backend/tasks/urls.py @@ -9,6 +9,7 @@ stopping_celery_tasks, resume_celery_task, delete_celery_task, + TransliterationAPIView, ) router = routers.DefaultRouter() @@ -21,4 +22,9 @@ path("stopping_celery_tasks/", stopping_celery_tasks), path("resume_celery_task/", resume_celery_task), path("delete_celery_task/", delete_celery_task), + 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 991c4f141..c780c0536 100644 --- a/backend/tasks/views.py +++ b/backend/tasks/views.py @@ -59,6 +59,7 @@ from utils.date_time_conversions import utc_to_ist from django.db import IntegrityError +from rest_framework.views import APIView # Create your views here. @@ -2774,3 +2775,16 @@ def delete_celery_task(req): task.forget() return JsonResponse({"message": "Task deleted successfully"}, status=200) + + +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)