<reponame>AngellusMortis/boundlexx
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import include, path, re_path
from django.views import defaults as default_views
from django.views.generic.base import RedirectView
from django.views.static import serve

urlpatterns = [
    path(settings.ADMIN_URL, admin.site.urls),
    path("robots.txt", include("robots.urls")),
    path("favicon.ico/", RedirectView.as_view(url="/static/img/logo.ico")),
    # path("admin_tools/", include("admin_tools.urls")),
    path("api/", include("boundlexx.api.urls")),
    path("", RedirectView.as_view(url="/api/v1/"), name="go-to-default-api"),
] + static(
    settings.MEDIA_URL, document_root=settings.MEDIA_ROOT
)  # type: ignore

if settings.ENABLE_PROMETHEUS:
    urlpatterns += [
        path("", include("django_prometheus.urls")),
    ]

if settings.DEBUG:
    # This allows the error pages to be debugged during development, just visit
    # these url in browser to see how these error pages look like.
    urlpatterns += [
        path(
            "400/",
            default_views.bad_request,
            kwargs={"exception": Exception("Bad Request!")},
        ),
        path(
            "403/",
            default_views.permission_denied,
            kwargs={"exception": Exception("Permission Denied")},
        ),
        path(
            "404/",
            default_views.page_not_found,
            kwargs={"exception": Exception("Page not Found")},
        ),
        path("500/", default_views.server_error),
    ]
    if "debug_toolbar" in settings.INSTALLED_APPS:
        import debug_toolbar

        urlpatterns.insert(0, path("__debug__/", include(debug_toolbar.urls)))

elif settings.SERVE_STATIC_FILES_DEV:
    urlpatterns += [
        re_path(
            r"^" + settings.STATIC_URL[1:] + r"(?P<path>.*)$",
            serve,
            {"document_root": settings.STATIC_ROOT},
        ),
    ]

from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import include, path, re_path
from django.views import defaults as default_views
from django.views.generic.base import RedirectView
from django.views.static import serve

urlpatterns = [
    path(settings.ADMIN_URL, admin.site.urls),
    path("robots.txt", include("robots.urls")),
    path("favicon.ico/", RedirectView.as_view(url="/static/img/logo.ico")),
    # path("admin_tools/", include("admin_tools.urls")),
    path("api/", include("boundlexx.api.urls")),
    path("", RedirectView.as_view(url="/api/v1/"), name="go-to-default-api"),
] + static(
    settings.MEDIA_URL, document_root=settings.MEDIA_ROOT
)  # type: ignore

if settings.ENABLE_PROMETHEUS:
    urlpatterns += [
        path("", include("django_prometheus.urls")),
    ]

if settings.DEBUG:
    # This allows the error pages to be debugged during development, just visit
    # these url in browser to see how these error pages look like.
    urlpatterns += [
        path(
            "400/",
            default_views.bad_request,
            kwargs={"exception": Exception("Bad Request!")},
        ),
        path(
            "403/",
            default_views.permission_denied,
            kwargs={"exception": Exception("Permission Denied")},
        ),
        path(
            "404/",
            default_views.page_not_found,
            kwargs={"exception": Exception("Page not Found")},
        ),
        path("500/", default_views.server_error),
    ]
    if "debug_toolbar" in settings.INSTALLED_APPS:
        import debug_toolbar

        urlpatterns.insert(0, path("__debug__/", include(debug_toolbar.urls)))

elif settings.SERVE_STATIC_FILES_DEV:
    urlpatterns += [
        re_path(
            r"^" + settings.STATIC_URL[1:] + r"(?P<path>.*)$",
            serve,
            {"document_root": settings.STATIC_ROOT},
        ),
    ]
# path("admin_tools/", include("admin_tools.urls")), # type: ignore # This allows the error pages to be debugged during development, just visit # these url in browser to see how these error pages look like.