From a1048de0fe726965fc0b918a28945e8344647002 Mon Sep 17 00:00:00 2001 From: chunyu <12914@example.com> Date: Fri, 7 Aug 2026 19:14:52 +0800 Subject: [PATCH] add root status page --- chunyu_project/urls.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/chunyu_project/urls.py b/chunyu_project/urls.py index c11f71d..390122d 100644 --- a/chunyu_project/urls.py +++ b/chunyu_project/urls.py @@ -15,6 +15,7 @@ Including another URLconf 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin +from django.http import JsonResponse from django.urls import path, include from django.conf import settings from django.conf.urls.static import static @@ -27,6 +28,22 @@ from drf_yasg import openapi from utils.swagger_generator import GracefulOpenAPISchemaGenerator from shorturl.views import ShortUrlRedirectView + +def home_view(request): + return JsonResponse({ + "service": "可乐平台 API", + "status": "running", + "version": "1.0.0", + "docs": "/swagger/", + "admin": "/admin/", + "endpoints": { + "articles": "/article/articles/", + "learn": "/learn/courses/", + "user": "/user/", + "api_directory": "/api/apidirectory/", + }, + }) + schema_view = get_schema_view( openapi.Info( title="ChunYu API", @@ -39,6 +56,7 @@ schema_view = get_schema_view( ) urlpatterns = [ + path('', home_view, name='home'), path('i18n/setlang/', set_language, name='set_language'), path('admin/', admin.site.urls), path('swagger.json', schema_view.without_ui(cache_timeout=0), name='schema-json'),