from django.conf import settings
from django.conf.urls import handler400, handler404, handler500
from django.conf.urls.static import static
from django.contrib import admin
from django.shortcuts import render
from django.urls import path, include

from hub.services.views.errors import bad_request, page_not_found, server_error

handler400 = "hub.services.views.errors.bad_request"
handler404 = "hub.services.views.errors.page_not_found"
handler500 = "hub.services.views.errors.server_error"

urlpatterns = [
    path("admin/", admin.site.urls),
    path("", include("hub.services.urls")),
    path("broker/", include("hub.broker.urls", namespace="broker")),
]
if settings.DEBUG:
    urlpatterns += [
        path("__reload__/", include("django_browser_reload.urls")),
        path("schema-viewer/", include("schema_viewer.urls")),
        path("test-400/", lambda request: render(request, "400.html"), name="test_400"),
        path("test-404/", lambda request: render(request, "404.html"), name="test_404"),
        path("test-500/", lambda request: render(request, "500.html"), name="test_500"),
    ]
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
