Merge pull request #873 from ajgon/feature/healthcheck
This commit is contained in:
commit
569a4582dd
2 changed files with 24 additions and 7 deletions
|
@ -6,7 +6,7 @@ from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.views.generic.base import RedirectView
|
from django.views.generic.base import RedirectView
|
||||||
|
|
||||||
from core.views import HomepageView, SnapshotView, PublicIndexView, AddView
|
from core.views import HomepageView, SnapshotView, PublicIndexView, AddView, HealthCheckView
|
||||||
|
|
||||||
|
|
||||||
# print('DEBUG', settings.DEBUG)
|
# print('DEBUG', settings.DEBUG)
|
||||||
|
@ -32,6 +32,8 @@ urlpatterns = [
|
||||||
path('accounts/', include('django.contrib.auth.urls')),
|
path('accounts/', include('django.contrib.auth.urls')),
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
|
|
||||||
|
path('health/', HealthCheckView.as_view(), name='healthcheck'),
|
||||||
|
|
||||||
path('index.html', RedirectView.as_view(url='/')),
|
path('index.html', RedirectView.as_view(url='/')),
|
||||||
path('index.json', static.serve, {'document_root': settings.OUTPUT_DIR, 'path': 'index.json'}),
|
path('index.json', static.serve, {'document_root': settings.OUTPUT_DIR, 'path': 'index.json'}),
|
||||||
path('', HomepageView.as_view(), name='Home'),
|
path('', HomepageView.as_view(), name='Home'),
|
||||||
|
|
|
@ -295,3 +295,18 @@ class AddView(UserPassesTestMixin, FormView):
|
||||||
"form": AddLinkForm()
|
"form": AddLinkForm()
|
||||||
})
|
})
|
||||||
return render(template_name=self.template_name, request=self.request, context=context)
|
return render(template_name=self.template_name, request=self.request, context=context)
|
||||||
|
|
||||||
|
|
||||||
|
class HealthCheckView(View):
|
||||||
|
"""
|
||||||
|
A Django view that renders plain text "OK" for service discovery tools
|
||||||
|
"""
|
||||||
|
def get(self, request):
|
||||||
|
"""
|
||||||
|
Handle a GET request
|
||||||
|
"""
|
||||||
|
return HttpResponse(
|
||||||
|
'OK',
|
||||||
|
content_type='text/plain',
|
||||||
|
status=200
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue