diff --git a/backendapi/urls.py b/backendapi/urls.py index 692238f..d78b803 100644 --- a/backendapi/urls.py +++ b/backendapi/urls.py @@ -6,4 +6,5 @@ urlpatterns = [ path("nfctag/", views.scanned), + path("test", views.api_get, name="api_get"), ] diff --git a/backendapi/views.py b/backendapi/views.py index 9222937..6938ed4 100644 --- a/backendapi/views.py +++ b/backendapi/views.py @@ -1,8 +1,9 @@ -from django.shortcuts import render from django.views.decorators.csrf import csrf_exempt from django.views.decorators.http import require_POST from django.views.decorators.cache import never_cache from django.http import JsonResponse +from rest_framework.decorators import api_view +from rest_framework.response import Response from database.models import Attendant @@ -18,3 +19,11 @@ def scanned(request, tag: bytes): except Attendant.DoesNotExist: return JsonResponse({"error": "No such tag", "valid": False}, status=404) + + +@api_view(["GET", "POST"]) +def api_get(request): + if request.method == "GET": + return Response({"message": "GET request received"}, status=200) + elif request.method == "POST": + return Response({"message": "POST request received"}, status=200) diff --git a/config/settings.py b/config/settings.py index 0764513..0461969 100644 --- a/config/settings.py +++ b/config/settings.py @@ -44,6 +44,7 @@ # --- "database", "backendapi", + "rest_framework", ] MIDDLEWARE = [ diff --git a/requirements.txt b/requirements.txt index edb6592..dfdad0a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,5 @@ Django[all]==5.1.3 django-urlconfchecks==0.11.0 # TODO: Add to CI daphne==4.1.2 psycopg2-binary==2.9.10 +djangorestframework==3.15.2 +