48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
"""
|
|
Root URL configuration for rfiles.online.
|
|
|
|
Serves the main upload portal at the root path.
|
|
"""
|
|
|
|
from django.contrib import admin
|
|
from django.urls import path, include
|
|
from django.http import JsonResponse
|
|
from django.db import connection
|
|
|
|
from files.urls import api_urlpatterns as files_api_urls, public_urlpatterns as files_public_urls
|
|
from portal.views import ServiceWorkerView, ManifestView
|
|
from portal.views_shared_space import DirectUploadAPIView
|
|
|
|
|
|
def health_check(request):
|
|
"""Health check endpoint for Docker."""
|
|
try:
|
|
with connection.cursor() as cursor:
|
|
cursor.execute("SELECT 1")
|
|
db_status = "healthy"
|
|
except Exception as e:
|
|
db_status = f"unhealthy: {str(e)}"
|
|
|
|
status = {
|
|
"status": "healthy" if db_status == "healthy" else "unhealthy",
|
|
"database": db_status,
|
|
"service": "rfiles-api",
|
|
}
|
|
|
|
http_status = 200 if status["status"] == "healthy" else 503
|
|
return JsonResponse(status, status=http_status)
|
|
|
|
|
|
urlpatterns = [
|
|
# PWA files at root for proper scope
|
|
path("sw.js", ServiceWorkerView.as_view(), name="service_worker"),
|
|
path("manifest.json", ManifestView.as_view(), name="manifest"),
|
|
|
|
path("api/health/", health_check, name="health_check"),
|
|
path("api/upload/", DirectUploadAPIView.as_view(), name="direct_upload"),
|
|
path("admin/", admin.site.urls),
|
|
path("api/v1/", include(files_api_urls)),
|
|
path("s/", include(files_public_urls)),
|
|
path("", include("portal.urls")),
|
|
]
|