from django.core.handlers.wsgi import WSGIRequest
from django.http import HttpResponse
from django.shortcuts import render
from django.urls.exceptions import Resolver404
from django.views.decorators.http import require_GET, require_safe


@require_safe  # supports both GET and HEAD
def home(request: WSGIRequest) -> HttpResponse:
    """Render the home/index page."""
    return render(request, "general/index.html")


@require_GET
def handler404(request: WSGIRequest, exception: Resolver404 | None = None) -> HttpResponse:
    """Render a 404 error page."""
    return render(request, "404.html", status=404)


@require_GET
def handler500(request: WSGIRequest) -> HttpResponse:
    """Render a 500 error page."""
    return render(request, "500.html", status=500)
