mirror of
https://github.com/thecyberlearn/modern-django-starter.git
synced 2026-08-18 12:52:55 +00:00
Add health check endpoint for debugging
- Add /health/ endpoint that returns JSON without templates - Shows Django settings, file existence, and configuration - Use this to test if Django is running: https://dt.netcoptech.com/health/ - Helps diagnose if issue is templates, static files, or server config
This commit is contained in:
parent
7f9093741b
commit
5845f9ee13
@ -5,6 +5,7 @@ app_name = 'core'
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', views.home, name='home'),
|
path('', views.home, name='home'),
|
||||||
|
path('health/', views.health_check, name='health_check'),
|
||||||
path('admin-dashboard/', views.admin_dashboard, name='admin_dashboard'),
|
path('admin-dashboard/', views.admin_dashboard, name='admin_dashboard'),
|
||||||
path('staff-dashboard/', views.staff_dashboard, name='staff_dashboard'),
|
path('staff-dashboard/', views.staff_dashboard, name='staff_dashboard'),
|
||||||
]
|
]
|
||||||
@ -2,9 +2,22 @@ from django.shortcuts import render
|
|||||||
from django.contrib.auth.decorators import login_required, user_passes_test
|
from django.contrib.auth.decorators import login_required, user_passes_test
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
|
||||||
from django.views.generic import TemplateView
|
from django.views.generic import TemplateView
|
||||||
from django.http import HttpResponseForbidden
|
from django.http import HttpResponseForbidden, JsonResponse
|
||||||
|
from django.conf import settings
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
def health_check(request):
|
||||||
|
"""Simple health check that doesn't require templates or static files"""
|
||||||
|
return JsonResponse({
|
||||||
|
'status': 'ok',
|
||||||
|
'debug': settings.DEBUG,
|
||||||
|
'allowed_hosts': settings.ALLOWED_HOSTS,
|
||||||
|
'settings_module': os.environ.get('DJANGO_SETTINGS_MODULE', 'not set'),
|
||||||
|
'static_files_exist': os.path.exists('/app/theme/static/css/dist/styles.css'),
|
||||||
|
'staticfiles_dir': os.path.exists('/app/staticfiles')
|
||||||
|
})
|
||||||
|
|
||||||
def home(request):
|
def home(request):
|
||||||
return render(request, 'home.html')
|
return render(request, 'home.html')
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user