Skip to content

Commit

Permalink
Add simple / page. Fix #54
Browse files Browse the repository at this point in the history
  • Loading branch information
aapris committed Oct 25, 2023
1 parent df4df4d commit 717a493
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mittaridatapumppu-deviceregistry/deviceregistry/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
DeviceTypeViewSet,
MaintenanceLogViewSet,
OrganizationViewSet,
index,
)
from endpoints.views import HostViewSet, EndpointViewSet

Expand All @@ -51,6 +52,7 @@
path("admin/", admin.site.urls),
path("api/v1/", include(router.urls)),
path("api-auth/", include("rest_framework.urls", namespace="rest_framework")),
path("", index, name="index"),
]

# if settings.DEBUG:
Expand Down
12 changes: 12 additions & 0 deletions mittaridatapumppu-deviceregistry/devices/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import datetime

from django.contrib.auth.models import User
from django.http import JsonResponse
from rest_framework import permissions
from rest_framework import viewsets
from rest_framework.authentication import (
Expand Down Expand Up @@ -30,6 +33,15 @@
)


def index(request):
"""
Return a simple JSON response with the current time.
"""
now = datetime.datetime.now(datetime.timezone.utc)
ok_msg = {"status": "ok", "time": now.isoformat()}
return JsonResponse(ok_msg, status=200)


class UserViewSet(viewsets.ReadOnlyModelViewSet):
"""
API endpoint that allows users to be viewed or edited.
Expand Down

0 comments on commit 717a493

Please sign in to comment.