mat/backend/config/urls.py

40 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
URL configuration for new_materials_db project.
"""
from django.contrib import admin
from django.urls import path, include, re_path
from django.conf import settings
from django.conf.urls.static import static
from django.views.generic import TemplateView
from .views import upload_image, serve_h5
urlpatterns = [
path('admin/', admin.site.urls),
path('api/auth/', include('apps.authentication.urls')),
path('api/factory/', include('apps.factory.urls')),
path('api/brand/', include('apps.brand.urls')),
path('api/material/', include('apps.material.urls')),
path('api/dictionary/', include('apps.dictionary.urls')),
path('api/statistics/', include('apps.statistics.urls')),
path('api/upload/', upload_image, name='upload-image'),
]
# 开发环境下提供媒体文件服务
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static('/assets/', document_root=settings.BASE_DIR / 'dist' / 'assets')
# H5 子应用:必须放在 PC 通配路由之前
urlpatterns += [
re_path(r'^m/?$', serve_h5, name='h5-index'),
re_path(r'^m/(?P<path>.*)$', serve_h5, name='h5-assets'),
]
# 前端单页应用入口PC 端)
urlpatterns += [
re_path(r'^(?!api/|admin/|media/|m/).*$',
TemplateView.as_view(template_name='index.html'),
name='frontend-index'),
]