We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Consider dropping deploy preview support for redirects app
Do we need previews of the legacy redirects?

If not, we may be able to remove a lot of code from the redirects app.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pydis_site/apps/redirect/urls.py`
Content:
```
1 import dataclasses
2 import re
3 
4 import yaml
5 from django import conf
6 from django.http import HttpResponse
7 from django.urls import URLPattern, path
8 from django_distill import distill_path
9 
10 from pydis_site import settings
11 from pydis_site.apps.content import urls as pages_urls
12 from pydis_site.apps.redirect.views import CustomRedirectView
13 from pydis_site.apps.resources import urls as resources_urls
14 
15 app_name = "redirect"
16 
17 
18 __PARAMETER_REGEX = re.compile(r"<\w+:\w+>")
19 REDIRECT_TEMPLATE = "<meta http-equiv=\"refresh\" content=\"0; URL={url}\"/>"
20 
21 
22 @dataclasses.dataclass(frozen=True)
23 class Redirect:
24     """Metadata about a redirect route."""
25 
26     original_path: str
27     redirect_route: str
28     redirect_arguments: tuple[str] = tuple()
29 
30     prefix_redirect: bool = False
31 
32 
33 def map_redirect(name: str, data: Redirect) -> list[URLPattern]:
34     """Return a pattern using the Redirects app, or a static HTML redirect for static builds."""
35     if not settings.STATIC_BUILD:
36         # Normal dynamic redirect
37         return [path(
38             data.original_path,
39             CustomRedirectView.as_view(
40                 pattern_name=data.redirect_route,
41                 static_args=tuple(data.redirect_arguments),
42                 prefix_redirect=data.prefix_redirect
43             ),
44             name=name
45         )]
46 
47     # Create static HTML redirects for static builds
48     new_app_name = data.redirect_route.split(":")[0]
49 
50     if __PARAMETER_REGEX.search(data.original_path):
51         # Redirects for paths which accept parameters
52         # We generate an HTML redirect file for all possible entries
53         paths = []
54 
55         class RedirectFunc:
56             def __init__(self, new_url: str, _name: str):
57                 self.result = HttpResponse(REDIRECT_TEMPLATE.format(url=new_url))
58                 self.__qualname__ = _name
59 
60             def __call__(self, *args, **kwargs):
61                 return self.result
62 
63         if new_app_name == resources_urls.app_name:
64             items = resources_urls.get_all_resources()
65         elif new_app_name == pages_urls.app_name:
66             items = pages_urls.get_all_pages()
67         else:
68             raise ValueError(f"Unknown app in redirect: {new_app_name}")
69 
70         for item in items:
71             entry = next(iter(item.values()))
72 
73             # Replace dynamic redirect with concrete path
74             concrete_path = __PARAMETER_REGEX.sub(entry, data.original_path)
75             new_redirect = f"/{new_app_name}/{entry}"
76             pattern_name = f"{name}_{entry}"
77 
78             paths.append(distill_path(
79                 concrete_path,
80                 RedirectFunc(new_redirect, pattern_name),
81                 name=pattern_name
82             ))
83 
84         return paths
85 
86     redirect_path_name = "pages" if new_app_name == "content" else new_app_name
87     if len(data.redirect_arguments) > 0:
88         redirect_arg = data.redirect_arguments[0]
89     else:
90         redirect_arg = "resources/"
91     new_redirect = f"/{redirect_path_name}/{redirect_arg}"
92 
93     if new_redirect == "/resources/resources/":
94         new_redirect = "/resources/"
95 
96     return [distill_path(
97         data.original_path,
98         lambda *args: HttpResponse(REDIRECT_TEMPLATE.format(url=new_redirect)),
99         name=name,
100     )]
101 
102 
103 urlpatterns = []
104 for _name, _data in yaml.safe_load(conf.settings.REDIRECTIONS_PATH.read_text()).items():
105     urlpatterns.extend(map_redirect(_name, Redirect(**_data)))
106
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/pydis_site/apps/redirect/urls.py b/pydis_site/apps/redirect/urls.py
--- a/pydis_site/apps/redirect/urls.py
+++ b/pydis_site/apps/redirect/urls.py
@@ -3,14 +3,9 @@
 
 import yaml
 from django import conf
-from django.http import HttpResponse
 from django.urls import URLPattern, path
-from django_distill import distill_path
 
-from pydis_site import settings
-from pydis_site.apps.content import urls as pages_urls
 from pydis_site.apps.redirect.views import CustomRedirectView
-from pydis_site.apps.resources import urls as resources_urls
 
 app_name = "redirect"
 
@@ -31,72 +26,15 @@
 
 
 def map_redirect(name: str, data: Redirect) -> list[URLPattern]:
-    """Return a pattern using the Redirects app, or a static HTML redirect for static builds."""
-    if not settings.STATIC_BUILD:
-        # Normal dynamic redirect
-        return [path(
-            data.original_path,
-            CustomRedirectView.as_view(
-                pattern_name=data.redirect_route,
-                static_args=tuple(data.redirect_arguments),
-                prefix_redirect=data.prefix_redirect
-            ),
-            name=name
-        )]
-
-    # Create static HTML redirects for static builds
-    new_app_name = data.redirect_route.split(":")[0]
-
-    if __PARAMETER_REGEX.search(data.original_path):
-        # Redirects for paths which accept parameters
-        # We generate an HTML redirect file for all possible entries
-        paths = []
-
-        class RedirectFunc:
-            def __init__(self, new_url: str, _name: str):
-                self.result = HttpResponse(REDIRECT_TEMPLATE.format(url=new_url))
-                self.__qualname__ = _name
-
-            def __call__(self, *args, **kwargs):
-                return self.result
-
-        if new_app_name == resources_urls.app_name:
-            items = resources_urls.get_all_resources()
-        elif new_app_name == pages_urls.app_name:
-            items = pages_urls.get_all_pages()
-        else:
-            raise ValueError(f"Unknown app in redirect: {new_app_name}")
-
-        for item in items:
-            entry = next(iter(item.values()))
-
-            # Replace dynamic redirect with concrete path
-            concrete_path = __PARAMETER_REGEX.sub(entry, data.original_path)
-            new_redirect = f"/{new_app_name}/{entry}"
-            pattern_name = f"{name}_{entry}"
-
-            paths.append(distill_path(
-                concrete_path,
-                RedirectFunc(new_redirect, pattern_name),
-                name=pattern_name
-            ))
-
-        return paths
-
-    redirect_path_name = "pages" if new_app_name == "content" else new_app_name
-    if len(data.redirect_arguments) > 0:
-        redirect_arg = data.redirect_arguments[0]
-    else:
-        redirect_arg = "resources/"
-    new_redirect = f"/{redirect_path_name}/{redirect_arg}"
-
-    if new_redirect == "/resources/resources/":
-        new_redirect = "/resources/"
-
-    return [distill_path(
+    """Return a pattern using the Redirects app."""
+    return [path(
         data.original_path,
-        lambda *args: HttpResponse(REDIRECT_TEMPLATE.format(url=new_redirect)),
-        name=name,
+        CustomRedirectView.as_view(
+            pattern_name=data.redirect_route,
+            static_args=tuple(data.redirect_arguments),
+            prefix_redirect=data.prefix_redirect
+        ),
+        name=name
     )]

{"golden_diff": "diff --git a/pydis_site/apps/redirect/urls.py b/pydis_site/apps/redirect/urls.py\n--- a/pydis_site/apps/redirect/urls.py\n+++ b/pydis_site/apps/redirect/urls.py\n@@ -3,14 +3,9 @@\n \n import yaml\n from django import conf\n-from django.http import HttpResponse\n from django.urls import URLPattern, path\n-from django_distill import distill_path\n \n-from pydis_site import settings\n-from pydis_site.apps.content import urls as pages_urls\n from pydis_site.apps.redirect.views import CustomRedirectView\n-from pydis_site.apps.resources import urls as resources_urls\n \n app_name = \"redirect\"\n \n@@ -31,72 +26,15 @@\n \n \n def map_redirect(name: str, data: Redirect) -> list[URLPattern]:\n-    \"\"\"Return a pattern using the Redirects app, or a static HTML redirect for static builds.\"\"\"\n-    if not settings.STATIC_BUILD:\n-        # Normal dynamic redirect\n-        return [path(\n-            data.original_path,\n-            CustomRedirectView.as_view(\n-                pattern_name=data.redirect_route,\n-                static_args=tuple(data.redirect_arguments),\n-                prefix_redirect=data.prefix_redirect\n-            ),\n-            name=name\n-        )]\n-\n-    # Create static HTML redirects for static builds\n-    new_app_name = data.redirect_route.split(\":\")[0]\n-\n-    if __PARAMETER_REGEX.search(data.original_path):\n-        # Redirects for paths which accept parameters\n-        # We generate an HTML redirect file for all possible entries\n-        paths = []\n-\n-        class RedirectFunc:\n-            def __init__(self, new_url: str, _name: str):\n-                self.result = HttpResponse(REDIRECT_TEMPLATE.format(url=new_url))\n-                self.__qualname__ = _name\n-\n-            def __call__(self, *args, **kwargs):\n-                return self.result\n-\n-        if new_app_name == resources_urls.app_name:\n-            items = resources_urls.get_all_resources()\n-        elif new_app_name == pages_urls.app_name:\n-            items = pages_urls.get_all_pages()\n-        else:\n-            raise ValueError(f\"Unknown app in redirect: {new_app_name}\")\n-\n-        for item in items:\n-            entry = next(iter(item.values()))\n-\n-            # Replace dynamic redirect with concrete path\n-            concrete_path = __PARAMETER_REGEX.sub(entry, data.original_path)\n-            new_redirect = f\"/{new_app_name}/{entry}\"\n-            pattern_name = f\"{name}_{entry}\"\n-\n-            paths.append(distill_path(\n-                concrete_path,\n-                RedirectFunc(new_redirect, pattern_name),\n-                name=pattern_name\n-            ))\n-\n-        return paths\n-\n-    redirect_path_name = \"pages\" if new_app_name == \"content\" else new_app_name\n-    if len(data.redirect_arguments) > 0:\n-        redirect_arg = data.redirect_arguments[0]\n-    else:\n-        redirect_arg = \"resources/\"\n-    new_redirect = f\"/{redirect_path_name}/{redirect_arg}\"\n-\n-    if new_redirect == \"/resources/resources/\":\n-        new_redirect = \"/resources/\"\n-\n-    return [distill_path(\n+    \"\"\"Return a pattern using the Redirects app.\"\"\"\n+    return [path(\n         data.original_path,\n-        lambda *args: HttpResponse(REDIRECT_TEMPLATE.format(url=new_redirect)),\n-        name=name,\n+        CustomRedirectView.as_view(\n+            pattern_name=data.redirect_route,\n+            static_args=tuple(data.redirect_arguments),\n+            prefix_redirect=data.prefix_redirect\n+        ),\n+        name=name\n     )]\n", "issue": "Consider dropping deploy preview support for redirects app\nDo we need previews of the legacy redirects?\n\nIf not, we may be able to remove a lot of code from the redirects app.\n", "before_files": [{"content": "import dataclasses\nimport re\n\nimport yaml\nfrom django import conf\nfrom django.http import HttpResponse\nfrom django.urls import URLPattern, path\nfrom django_distill import distill_path\n\nfrom pydis_site import settings\nfrom pydis_site.apps.content import urls as pages_urls\nfrom pydis_site.apps.redirect.views import CustomRedirectView\nfrom pydis_site.apps.resources import urls as resources_urls\n\napp_name = \"redirect\"\n\n\n__PARAMETER_REGEX = re.compile(r\"<\\w+:\\w+>\")\nREDIRECT_TEMPLATE = \"<meta http-equiv=\\\"refresh\\\" content=\\\"0; URL={url}\\\"/>\"\n\n\n@dataclasses.dataclass(frozen=True)\nclass Redirect:\n    \"\"\"Metadata about a redirect route.\"\"\"\n\n    original_path: str\n    redirect_route: str\n    redirect_arguments: tuple[str] = tuple()\n\n    prefix_redirect: bool = False\n\n\ndef map_redirect(name: str, data: Redirect) -> list[URLPattern]:\n    \"\"\"Return a pattern using the Redirects app, or a static HTML redirect for static builds.\"\"\"\n    if not settings.STATIC_BUILD:\n        # Normal dynamic redirect\n        return [path(\n            data.original_path,\n            CustomRedirectView.as_view(\n                pattern_name=data.redirect_route,\n                static_args=tuple(data.redirect_arguments),\n                prefix_redirect=data.prefix_redirect\n            ),\n            name=name\n        )]\n\n    # Create static HTML redirects for static builds\n    new_app_name = data.redirect_route.split(\":\")[0]\n\n    if __PARAMETER_REGEX.search(data.original_path):\n        # Redirects for paths which accept parameters\n        # We generate an HTML redirect file for all possible entries\n        paths = []\n\n        class RedirectFunc:\n            def __init__(self, new_url: str, _name: str):\n                self.result = HttpResponse(REDIRECT_TEMPLATE.format(url=new_url))\n                self.__qualname__ = _name\n\n            def __call__(self, *args, **kwargs):\n                return self.result\n\n        if new_app_name == resources_urls.app_name:\n            items = resources_urls.get_all_resources()\n        elif new_app_name == pages_urls.app_name:\n            items = pages_urls.get_all_pages()\n        else:\n            raise ValueError(f\"Unknown app in redirect: {new_app_name}\")\n\n        for item in items:\n            entry = next(iter(item.values()))\n\n            # Replace dynamic redirect with concrete path\n            concrete_path = __PARAMETER_REGEX.sub(entry, data.original_path)\n            new_redirect = f\"/{new_app_name}/{entry}\"\n            pattern_name = f\"{name}_{entry}\"\n\n            paths.append(distill_path(\n                concrete_path,\n                RedirectFunc(new_redirect, pattern_name),\n                name=pattern_name\n            ))\n\n        return paths\n\n    redirect_path_name = \"pages\" if new_app_name == \"content\" else new_app_name\n    if len(data.redirect_arguments) > 0:\n        redirect_arg = data.redirect_arguments[0]\n    else:\n        redirect_arg = \"resources/\"\n    new_redirect = f\"/{redirect_path_name}/{redirect_arg}\"\n\n    if new_redirect == \"/resources/resources/\":\n        new_redirect = \"/resources/\"\n\n    return [distill_path(\n        data.original_path,\n        lambda *args: HttpResponse(REDIRECT_TEMPLATE.format(url=new_redirect)),\n        name=name,\n    )]\n\n\nurlpatterns = []\nfor _name, _data in yaml.safe_load(conf.settings.REDIRECTIONS_PATH.read_text()).items():\n    urlpatterns.extend(map_redirect(_name, Redirect(**_data)))\n", "path": "pydis_site/apps/redirect/urls.py"}], "after_files": [{"content": "import dataclasses\nimport re\n\nimport yaml\nfrom django import conf\nfrom django.urls import URLPattern, path\n\nfrom pydis_site.apps.redirect.views import CustomRedirectView\n\napp_name = \"redirect\"\n\n\n__PARAMETER_REGEX = re.compile(r\"<\\w+:\\w+>\")\nREDIRECT_TEMPLATE = \"<meta http-equiv=\\\"refresh\\\" content=\\\"0; URL={url}\\\"/>\"\n\n\n@dataclasses.dataclass(frozen=True)\nclass Redirect:\n    \"\"\"Metadata about a redirect route.\"\"\"\n\n    original_path: str\n    redirect_route: str\n    redirect_arguments: tuple[str] = tuple()\n\n    prefix_redirect: bool = False\n\n\ndef map_redirect(name: str, data: Redirect) -> list[URLPattern]:\n    \"\"\"Return a pattern using the Redirects app.\"\"\"\n    return [path(\n        data.original_path,\n        CustomRedirectView.as_view(\n            pattern_name=data.redirect_route,\n            static_args=tuple(data.redirect_arguments),\n            prefix_redirect=data.prefix_redirect\n        ),\n        name=name\n    )]\n\n\nurlpatterns = []\nfor _name, _data in yaml.safe_load(conf.settings.REDIRECTIONS_PATH.read_text()).items():\n    urlpatterns.extend(map_redirect(_name, Redirect(**_data)))\n", "path": "pydis_site/apps/redirect/urls.py"}]}