Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simple / page. Fix #54 #55

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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