From 9d5271e0e74c1dbe67d7d2647801706fd8338b34 Mon Sep 17 00:00:00 2001 From: Florian Knappers <73856313+JJFlorian@users.noreply.github.com> Date: Mon, 8 Apr 2024 15:18:41 +0200 Subject: [PATCH] added localhost redirect --- api/urls.py | 1 + api/views.py | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/api/urls.py b/api/urls.py index 7cded73..049da9c 100644 --- a/api/urls.py +++ b/api/urls.py @@ -10,6 +10,7 @@ urlpatterns = [ path("", views.APIOverview.as_view(), name="overview"), + path("localhost-redirect", views.LocalHostRedirectView.as_view(), name="localhost"), path("gmn/", include(("gmn.urls", "gmn"), namespace="gmn")), path("gmw/", include(("gmw.urls", "gmw"), namespace="gmw")), path("importtasks/", views.ImportTaskListView.as_view(), name="importtask-list"), diff --git a/api/views.py b/api/views.py index fb561d0..abfd3f2 100644 --- a/api/views.py +++ b/api/views.py @@ -1,5 +1,6 @@ from django.contrib.auth import logout from django.contrib.auth.models import User +from django.http import HttpResponseRedirect from django.shortcuts import redirect from django_filters.rest_framework import DjangoFilterBackend from drf_yasg.utils import swagger_auto_schema @@ -7,6 +8,7 @@ from rest_framework.decorators import action from rest_framework.response import Response from rest_framework.reverse import reverse +from rest_framework.views import APIView from . import filters, mixins, models, serializers, tasks @@ -50,6 +52,16 @@ def get(self, request, format=None): return Response(data) +class LocalHostRedirectView(APIView): + """ + View that redirects user to localhost:4200. + Is used for local frontend development on the stagin environment. + """ + + def get(self, request, *args, **kwargs): + return HttpResponseRedirect("http://localhost:4200") + + class UserViewSet(viewsets.ModelViewSet): model = User serializer_class = serializers.UserSerializer