urls.py 2.3 KB

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