diff --git a/transcendence/urls.py b/transcendence/urls.py index d0d06ad..fd3d6d9 100644 --- a/transcendence/urls.py +++ b/transcendence/urls.py @@ -15,7 +15,8 @@ Including another URLconf 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path, include +from django.urls import path, include, re_path +from .views import handler_404_view urlpatterns = [ path('admin/', admin.site.urls), @@ -24,5 +25,6 @@ urlpatterns = [ path('api/chat/', include('chat.urls')), path('api/tournaments/', include('tournament.urls')), path('api/games/', include('games.urls')), + re_path(r'^api/', handler_404_view), path('', include('frontend.urls')), ] diff --git a/transcendence/views.py b/transcendence/views.py new file mode 100644 index 0000000..06fbe9b --- /dev/null +++ b/transcendence/views.py @@ -0,0 +1,7 @@ +from rest_framework.response import Response +from rest_framework.decorators import api_view +from rest_framework import status + +@api_view(('GET',)) +def handler_404_view(request): + return Response(status=status.HTTP_404_NOT_FOUND);