add root status page
This commit is contained in:
@@ -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'),
|
||||
|
||||
Reference in New Issue
Block a user