model_train_dm/backend/config/urls.py

43 lines
1.6 KiB
Python
Raw Permalink Normal View History

2026-07-27 17:51:49 +08:00
from django.contrib import admin
from django.urls import include, path, re_path
from django.conf import settings
from django.conf.urls.static import static
from drf_yasg import openapi
from drf_yasg.views import get_schema_view
from rest_framework import permissions
from rest_framework_simplejwt import views as JWTAuthenticationViews
from apps.iam.views.user import UserLoginView
schema_view = get_schema_view(
openapi.Info(
title="Your API",
default_version="v1",
description="Your API description",
terms_of_service="https://www.yourapp.com/terms/",
contact=openapi.Contact(email="contact@yourapp.com"),
license=openapi.License(name="Your License"),
),
public=True,
permission_classes=(permissions.AllowAny,),
)
urlpatterns = [
path("admin/", admin.site.urls),
path("server/", include("config.api_urls")),
path("login/", UserLoginView.as_view(), name="user_login"),
path("api/token/", JWTAuthenticationViews.TokenObtainPairView.as_view(), name="get_token"),
path(
"api/token/refresh/",
JWTAuthenticationViews.TokenRefreshView.as_view(),
name="refresh_token",
),
path("api/token/verify/", JWTAuthenticationViews.TokenVerifyView.as_view(), name="token_verify"),
re_path(r"^swagger(?P<format>\.json|\.yaml)$", schema_view.without_ui(cache_timeout=0), name="schema-json"),
path("swagger/", schema_view.with_ui("swagger", cache_timeout=0), name="schema-swagger-ui"),
path("redoc/", schema_view.with_ui("redoc", cache_timeout=0), name="schema-redoc"),
]
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)