urls.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. from django.contrib import admin
  2. from django.conf import settings
  3. from django.urls import path, include, re_path
  4. from django.views.generic.base import TemplateView
  5. from django.contrib.staticfiles.views import serve
  6. from django.views.static import serve as static_serve
  7. from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView, SpectacularSwaggerView
  8. from . import views
  9. def return_static(request, path, insecure=True, **kwargs):
  10. return serve(request, path, insecure, **kwargs)
  11. urlpatterns = [
  12. path('login/', include('userlogin.urls')),
  13. path('register/', include('userregister.urls')),
  14. path('user/', include('userprofile.urls')),
  15. re_path(r'^favicon\.ico$', views.favicon, name='favicon'),
  16. re_path('^css/.*$', views.css, name='css'),
  17. re_path('^js/.*$', views.js, name='js'),
  18. re_path('^statics/.*$', views.statics, name='statics'),
  19. re_path('^fonts/.*$', views.fonts, name='fonts'),
  20. re_path(r'^robots.txt', views.robots, name='robots'),
  21. re_path(r'^media/(?P<path>.*)$', static_serve, {'document_root': settings.MEDIA_ROOT}),
  22. re_path(r'^static/(?P<path>.*)$', return_static, name='static')
  23. ]
  24. urlpatterns += [
  25. path('api/', SpectacularAPIView.as_view(), name='schema'),
  26. # Optional UI:
  27. path('api/debug/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
  28. path('api/docs/', SpectacularRedocView.as_view(url_name='schema'), name='docs'),
  29. ]