Skip to content

Commit

Permalink
Feat: Remove hello_world view from api/urls.py and view
Browse files Browse the repository at this point in the history
  • Loading branch information
SverreNystad committed Jan 4, 2024
1 parent e6a341a commit 0c9b27d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 27 deletions.
2 changes: 0 additions & 2 deletions backend/api/urls.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from django.urls import path

from api.views import hello_world
from users.views import LoginView, RegisterUser

urlpatterns = [
path("hello_word", hello_world),
path("create-user/", RegisterUser, name="create-user"),
path("login/", LoginView, name="login"),
]
25 changes: 0 additions & 25 deletions backend/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,3 @@

# Define your expected request body as a serializer
from rest_framework import serializers


class HelloWorldSerializer(serializers.Serializer):
name = serializers.CharField(
required=True, help_text="Name of the person to greet."
)


@swagger_auto_schema(
method="post",
request_body=HelloWorldSerializer,
operation_description="Post a name and receive a 'Hello' greeting in return.",
)
@api_view(["POST"])
def hello_world(request):
"""
POST:
Receive a name in the request body and return a greeting.
"""
serializer = HelloWorldSerializer(data=request.data)
if serializer.is_valid():
name = serializer.validated_data.get("name")
return Response(f"Hello {name}")
else:
return Response(serializer.errors, status=400)

0 comments on commit 0c9b27d

Please sign in to comment.