Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

created a proxy endpoint for xlit api #1122

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions backend/tasks/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
stopping_celery_tasks,
resume_celery_task,
delete_celery_task,
TransliterationAPIView,
)

router = routers.DefaultRouter()
Expand All @@ -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/<str:target_language>/<str:data>",
TransliterationAPIView.as_view(),
name="transliteration-api",
),
] + router.urls
14 changes: 14 additions & 0 deletions backend/tasks/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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)
Loading