Skip to content

Commit

Permalink
Add health check endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
quantum5 committed Jan 2, 2025
1 parent 7ff577f commit 1a60694
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion qlinks/urls/short.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

from django.urls import path

from qlinks.views import short_link
from qlinks.views import health_check, short_link

urlpatterns = [
path('', partial(short_link, path=''), name='short_link'),
path('api/health_check', health_check, name='health_check'),
path('<path:path>', short_link, name='short_link'),
]
7 changes: 6 additions & 1 deletion qlinks/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.conf import settings
from django.http import HttpResponseRedirect
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404

from qlinks.models import Link
Expand All @@ -10,3 +10,8 @@ def short_link(request, path):
return HttpResponseRedirect(link, headers={
'X-Powered-By': settings.QLINKS_POWERED_BY
})


def health_check(request):
Link.objects.exists()
return HttpResponse('qlinks seems to work!')

0 comments on commit 1a60694

Please sign in to comment.