urls.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. from django.conf import settings
  2. from django.conf.urls.static import static
  3. from django.contrib import admin
  4. from django.urls import include, path, re_path
  5. from django.views.generic import TemplateView
  6. from django.views.generic.base import RedirectView
  7. from organizations.backends import invitation_backend
  8. from apps.event_ingest.views import event_envelope_view
  9. from .api.api import api
  10. from .views import health, index
  11. urlpatterns = [
  12. path("_health/", health),
  13. re_path(
  14. r"^favicon\.ico$",
  15. RedirectView.as_view(url=settings.STATIC_URL + "favicon.ico", permanent=True),
  16. ),
  17. path(
  18. "robots.txt",
  19. TemplateView.as_view(template_name="robots.txt", content_type="text/plain"),
  20. ),
  21. path("api/<int:project_id>/envelope/", event_envelope_view),
  22. path("api/", RedirectView.as_view(url="/profile/auth-tokens")),
  23. # OSS Sentry compat - redirect the non-api prefix url to the more typical api prefix
  24. path(
  25. "organizations/<slug:organization_slug>/issues/<int:issue_id>/events/<event_id>/json/",
  26. RedirectView.as_view(
  27. url="/api/0/organizations/%(organization_slug)s/issues/%(issue_id)s/events/%(event_id)s/json/",
  28. ),
  29. ),
  30. path("api/", api.urls),
  31. ]
  32. if "django.contrib.admin" in settings.INSTALLED_APPS:
  33. urlpatterns += [
  34. path("admin/", admin.site.urls),
  35. ]
  36. urlpatterns += [
  37. path("", include("apps.uptime.urls")),
  38. path("api/test/", include("test_api.urls")),
  39. path("accounts/", include("allauth.urls")),
  40. path("_allauth/", include("allauth.headless.urls")),
  41. # These routes belong to the Angular single page app
  42. re_path(r"^$", index),
  43. re_path(
  44. r"^(auth|login|register|(.*)/issues|(.*)/settings|(.*)/performance|(.*)/projects|(.*)/releases|organizations|profile|(.*)/uptime-monitors|accept|reset-password).*$",
  45. index,
  46. ),
  47. path("accept/", include(invitation_backend().get_urls())),
  48. ]
  49. if settings.BILLING_ENABLED:
  50. urlpatterns.append(path("stripe/", include("djstripe.urls", namespace="djstripe")))
  51. if settings.DEBUG_TOOLBAR:
  52. urlpatterns.append(path("__debug__/", include("debug_toolbar.urls")))
  53. if settings.DEBUG:
  54. urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)