fix: 404 response on wrong api calls

This commit is contained in:
AdrienLSH 2024-01-18 12:41:29 +01:00
parent dee71c7c8d
commit dae01c6821
2 changed files with 10 additions and 1 deletions

View File

@ -15,7 +15,8 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
""" """
from django.contrib import admin 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 = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
@ -24,5 +25,6 @@ urlpatterns = [
path('api/chat/', include('chat.urls')), path('api/chat/', include('chat.urls')),
path('api/tournaments/', include('tournament.urls')), path('api/tournaments/', include('tournament.urls')),
path('api/games/', include('games.urls')), path('api/games/', include('games.urls')),
re_path(r'^api/', handler_404_view),
path('', include('frontend.urls')), path('', include('frontend.urls')),
] ]

7
transcendence/views.py Normal file
View File

@ -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);