You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.7 KiB

3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
1 year ago
2 years ago
  1. """app URL Configuration
  2. The `urlpatterns` list routes URLs to views. For more information please see:
  3. https://docs.djangoproject.com/en/2.0/topics/http/urls/
  4. Examples:
  5. Function views
  6. 1. Add an import: from my_app import views
  7. 2. Add a URL to urlpatterns: path('', views.home, name='home')
  8. Class-based views
  9. 1. Add an import: from other_app.views import Home
  10. 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
  11. Including another URLconf
  12. 1. Import the include() function: from django.urls import include, path
  13. 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
  14. """
  15. import os
  16. import re
  17. from pathlib import Path
  18. from django.conf import settings
  19. from django.contrib import admin
  20. from django.contrib.auth.views import TemplateView
  21. from django.urls import include, path, re_path
  22. from django.views.static import serve
  23. from drf_yasg import openapi
  24. from drf_yasg.views import get_schema_view
  25. schema_view = get_schema_view(
  26. openapi.Info(
  27. title="doccano API",
  28. default_version="v1",
  29. description="doccano API description",
  30. license=openapi.License(name="MIT License"),
  31. ),
  32. public=True,
  33. )
  34. urlpatterns = []
  35. if settings.DEBUG or os.environ.get("STANDALONE", False):
  36. static_dir = Path(__file__).resolve().parent.parent / "client" / "dist"
  37. # For showing images and audios in the case of pip and Docker.
  38. urlpatterns.append(
  39. re_path(
  40. r"^%s(?P<path>.*)$" % re.escape(settings.MEDIA_URL.lstrip("/")),
  41. serve,
  42. {"document_root": settings.MEDIA_ROOT},
  43. )
  44. )
  45. # For showing favicon on the case of pip and Docker.
  46. urlpatterns.append(path("favicon.ico", serve, {"document_root": static_dir, "path": "favicon.ico"}))
  47. urlpatterns += [
  48. path("admin/", admin.site.urls),
  49. path("api-auth/", include("rest_framework.urls")),
  50. path("social/", include("social.urls")),
  51. path("v1/social/", include("social.v1_urls")),
  52. path("v1/health/", include("health_check.urls")),
  53. path("v1/", include("api.urls")),
  54. path("v1/", include("roles.urls")),
  55. path("v1/", include("users.urls")),
  56. path("v1/", include("data_import.urls")),
  57. path("v1/", include("data_export.urls")),
  58. path("v1/", include("projects.urls")),
  59. path("v1/projects/<int:project_id>/metrics/", include("metrics.urls")),
  60. path("v1/projects/<int:project_id>/", include("auto_labeling.urls")),
  61. path("v1/projects/<int:project_id>/", include("examples.urls")),
  62. path("v1/projects/<int:project_id>/", include("labels.urls")),
  63. path("v1/projects/<int:project_id>/", include("label_types.urls")),
  64. path("swagger/", schema_view.with_ui("swagger", cache_timeout=0), name="schema-swagger-ui"),
  65. re_path("", TemplateView.as_view(template_name="index.html")),
  66. ]