We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Support multiple page resources
Currently the create image function for a resource return a single image. Instead it should return a list of images, which would allow multiple page resources.

For example, for 4 pages of a single page resource the content would be:

```
Image output: [A]
Final document: A, A, A, A
```

For 4 pages of a three page resource the content would be:

```
Image output: [A, B, C], [A, B, C], [A, B, C], [A, B, C] 
Final document: A, B, C, A, B, C, A, B, C, A, B, C
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `csunplugged/resources/views/generate_resource_pdf.py`
Content:
```
1 """Module for generating custom resource PDFs."""
2 
3 from django.http import HttpResponse
4 from django.template.loader import render_to_string
5 from django.contrib.staticfiles import finders
6 from django.conf import settings
7 from PIL import Image
8 from io import BytesIO
9 import importlib
10 import base64
11 
12 RESPONSE_CONTENT_DISPOSITION = 'attachment; filename="{filename}.pdf"'
13 MM_TO_PIXEL_RATIO = 3.78
14 
15 
16 def generate_resource_pdf(request, resource, module_path):
17     """Return a response containing a generated PDF resource.
18 
19     Args:
20         request: HTTP request object
21         resource: Object of resource data.
22         module_path: Path to module for generating resource.
23 
24     Returns:
25         HTTP response containing generated resource PDF.
26     """
27     # TODO: Weasyprint handling in production
28     import environ
29     env = environ.Env(
30         DJANGO_PRODUCTION=(bool),
31     )
32     if env("DJANGO_PRODUCTION"):
33         return HttpResponse("<html><body>PDF generation is currently not supported in production.</body></html>")
34     else:
35         from weasyprint import HTML, CSS
36         context = dict()
37         get_request = request.GET
38         context["paper_size"] = get_request["paper_size"]
39         context["resource"] = resource
40         context["header_text"] = get_request["header_text"]
41 
42         resource_image_generator = importlib.import_module(module_path)
43         filename = "{} ({})".format(resource.name, resource_image_generator.subtitle(get_request, resource))
44         context["filename"] = filename
45 
46         num_copies = range(0, int(get_request["copies"]))
47         context["resource_images"] = []
48         for copy in num_copies:
49             context["resource_images"].append(
50                 generate_resource_image(get_request, resource, module_path)
51             )
52 
53         pdf_html = render_to_string("resources/base-resource-pdf.html", context)
54         html = HTML(string=pdf_html, base_url=settings.STATIC_ROOT)
55         css_file = finders.find("css/print-resource-pdf.css")
56         css_string = open(css_file, encoding="UTF-8").read()
57         base_css = CSS(string=css_string)
58         pdf_file = html.write_pdf(stylesheets=[base_css])
59 
60         response = HttpResponse(pdf_file, content_type="application/pdf")
61         response["Content-Disposition"] = RESPONSE_CONTENT_DISPOSITION.format(filename=filename)
62         return response
63 
64 
65 def generate_resource_image(get_request, resource, module_path):
66     """Retrieve image from resource generator and resize to size.
67 
68     Args:
69         get_request: HTTP request object
70         resource: Object of resource data.
71         module_path: Path to module for generating resource.
72 
73     Returns:
74         Base64 string of a generated resource image.
75     """
76     # Get image from resource image creator
77     resource_image_generator = importlib.import_module(module_path)
78     image = resource_image_generator.resource_image(get_request, resource)
79 
80     # Resize image to reduce file size
81     if get_request["paper_size"] == "a4":
82         max_pixel_height = 267 * MM_TO_PIXEL_RATIO
83     elif get_request["paper_size"] == "letter":
84         max_pixel_height = 249 * MM_TO_PIXEL_RATIO
85     (width, height) = image.size
86     if height > max_pixel_height:
87         ratio = max_pixel_height / height
88         width *= ratio
89         height *= ratio
90         image = image.resize((int(width), int(height)), Image.ANTIALIAS)
91 
92     # Save image to buffer
93     image_buffer = BytesIO()
94     image.save(image_buffer, format="PNG")
95 
96     # Return base64 of image
97     return base64.b64encode(image_buffer.getvalue())
98
```
--- 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/csunplugged/resources/views/generate_resource_pdf.py b/csunplugged/resources/views/generate_resource_pdf.py
--- a/csunplugged/resources/views/generate_resource_pdf.py
+++ b/csunplugged/resources/views/generate_resource_pdf.py
@@ -63,7 +63,9 @@
 
 
 def generate_resource_image(get_request, resource, module_path):
-    """Retrieve image from resource generator and resize to size.
+    """Retrieve image(s) for one copy of resource from resource generator.
+
+    Images are resized to size.
 
     Args:
         get_request: HTTP request object
@@ -71,27 +73,33 @@
         module_path: Path to module for generating resource.
 
     Returns:
-        Base64 string of a generated resource image.
+        List of Base64 strings of a generated resource images for one copy.
     """
-    # Get image from resource image creator
+    # Get images from resource image creator
     resource_image_generator = importlib.import_module(module_path)
-    image = resource_image_generator.resource_image(get_request, resource)
+    raw_images = resource_image_generator.resource_image(get_request, resource)
+    if not isinstance(raw_images, list):
+        raw_images = [raw_images]
 
-    # Resize image to reduce file size
+    # Resize images to reduce file size
     if get_request["paper_size"] == "a4":
         max_pixel_height = 267 * MM_TO_PIXEL_RATIO
     elif get_request["paper_size"] == "letter":
         max_pixel_height = 249 * MM_TO_PIXEL_RATIO
-    (width, height) = image.size
-    if height > max_pixel_height:
-        ratio = max_pixel_height / height
-        width *= ratio
-        height *= ratio
-        image = image.resize((int(width), int(height)), Image.ANTIALIAS)
-
-    # Save image to buffer
-    image_buffer = BytesIO()
-    image.save(image_buffer, format="PNG")
-
-    # Return base64 of image
-    return base64.b64encode(image_buffer.getvalue())
+
+    images = []
+    for image in raw_images:
+        (width, height) = image.size
+        if height > max_pixel_height:
+            ratio = max_pixel_height / height
+            width *= ratio
+            height *= ratio
+            image = image.resize((int(width), int(height)), Image.ANTIALIAS)
+
+        # Save image to buffer
+        image_buffer = BytesIO()
+        image.save(image_buffer, format="PNG")
+        # Add base64 of image to list of images
+        images.append(base64.b64encode(image_buffer.getvalue()))
+
+    return images

{"golden_diff": "diff --git a/csunplugged/resources/views/generate_resource_pdf.py b/csunplugged/resources/views/generate_resource_pdf.py\n--- a/csunplugged/resources/views/generate_resource_pdf.py\n+++ b/csunplugged/resources/views/generate_resource_pdf.py\n@@ -63,7 +63,9 @@\n \n \n def generate_resource_image(get_request, resource, module_path):\n-    \"\"\"Retrieve image from resource generator and resize to size.\n+    \"\"\"Retrieve image(s) for one copy of resource from resource generator.\n+\n+    Images are resized to size.\n \n     Args:\n         get_request: HTTP request object\n@@ -71,27 +73,33 @@\n         module_path: Path to module for generating resource.\n \n     Returns:\n-        Base64 string of a generated resource image.\n+        List of Base64 strings of a generated resource images for one copy.\n     \"\"\"\n-    # Get image from resource image creator\n+    # Get images from resource image creator\n     resource_image_generator = importlib.import_module(module_path)\n-    image = resource_image_generator.resource_image(get_request, resource)\n+    raw_images = resource_image_generator.resource_image(get_request, resource)\n+    if not isinstance(raw_images, list):\n+        raw_images = [raw_images]\n \n-    # Resize image to reduce file size\n+    # Resize images to reduce file size\n     if get_request[\"paper_size\"] == \"a4\":\n         max_pixel_height = 267 * MM_TO_PIXEL_RATIO\n     elif get_request[\"paper_size\"] == \"letter\":\n         max_pixel_height = 249 * MM_TO_PIXEL_RATIO\n-    (width, height) = image.size\n-    if height > max_pixel_height:\n-        ratio = max_pixel_height / height\n-        width *= ratio\n-        height *= ratio\n-        image = image.resize((int(width), int(height)), Image.ANTIALIAS)\n-\n-    # Save image to buffer\n-    image_buffer = BytesIO()\n-    image.save(image_buffer, format=\"PNG\")\n-\n-    # Return base64 of image\n-    return base64.b64encode(image_buffer.getvalue())\n+\n+    images = []\n+    for image in raw_images:\n+        (width, height) = image.size\n+        if height > max_pixel_height:\n+            ratio = max_pixel_height / height\n+            width *= ratio\n+            height *= ratio\n+            image = image.resize((int(width), int(height)), Image.ANTIALIAS)\n+\n+        # Save image to buffer\n+        image_buffer = BytesIO()\n+        image.save(image_buffer, format=\"PNG\")\n+        # Add base64 of image to list of images\n+        images.append(base64.b64encode(image_buffer.getvalue()))\n+\n+    return images\n", "issue": "Support multiple page resources\nCurrently the create image function for a resource return a single image. Instead it should return a list of images, which would allow multiple page resources.\r\n\r\nFor example, for 4 pages of a single page resource the content would be:\r\n\r\n```\r\nImage output: [A]\r\nFinal document: A, A, A, A\r\n```\r\n\r\nFor 4 pages of a three page resource the content would be:\r\n\r\n```\r\nImage output: [A, B, C], [A, B, C], [A, B, C], [A, B, C] \r\nFinal document: A, B, C, A, B, C, A, B, C, A, B, C\r\n```\n", "before_files": [{"content": "\"\"\"Module for generating custom resource PDFs.\"\"\"\n\nfrom django.http import HttpResponse\nfrom django.template.loader import render_to_string\nfrom django.contrib.staticfiles import finders\nfrom django.conf import settings\nfrom PIL import Image\nfrom io import BytesIO\nimport importlib\nimport base64\n\nRESPONSE_CONTENT_DISPOSITION = 'attachment; filename=\"{filename}.pdf\"'\nMM_TO_PIXEL_RATIO = 3.78\n\n\ndef generate_resource_pdf(request, resource, module_path):\n    \"\"\"Return a response containing a generated PDF resource.\n\n    Args:\n        request: HTTP request object\n        resource: Object of resource data.\n        module_path: Path to module for generating resource.\n\n    Returns:\n        HTTP response containing generated resource PDF.\n    \"\"\"\n    # TODO: Weasyprint handling in production\n    import environ\n    env = environ.Env(\n        DJANGO_PRODUCTION=(bool),\n    )\n    if env(\"DJANGO_PRODUCTION\"):\n        return HttpResponse(\"<html><body>PDF generation is currently not supported in production.</body></html>\")\n    else:\n        from weasyprint import HTML, CSS\n        context = dict()\n        get_request = request.GET\n        context[\"paper_size\"] = get_request[\"paper_size\"]\n        context[\"resource\"] = resource\n        context[\"header_text\"] = get_request[\"header_text\"]\n\n        resource_image_generator = importlib.import_module(module_path)\n        filename = \"{} ({})\".format(resource.name, resource_image_generator.subtitle(get_request, resource))\n        context[\"filename\"] = filename\n\n        num_copies = range(0, int(get_request[\"copies\"]))\n        context[\"resource_images\"] = []\n        for copy in num_copies:\n            context[\"resource_images\"].append(\n                generate_resource_image(get_request, resource, module_path)\n            )\n\n        pdf_html = render_to_string(\"resources/base-resource-pdf.html\", context)\n        html = HTML(string=pdf_html, base_url=settings.STATIC_ROOT)\n        css_file = finders.find(\"css/print-resource-pdf.css\")\n        css_string = open(css_file, encoding=\"UTF-8\").read()\n        base_css = CSS(string=css_string)\n        pdf_file = html.write_pdf(stylesheets=[base_css])\n\n        response = HttpResponse(pdf_file, content_type=\"application/pdf\")\n        response[\"Content-Disposition\"] = RESPONSE_CONTENT_DISPOSITION.format(filename=filename)\n        return response\n\n\ndef generate_resource_image(get_request, resource, module_path):\n    \"\"\"Retrieve image from resource generator and resize to size.\n\n    Args:\n        get_request: HTTP request object\n        resource: Object of resource data.\n        module_path: Path to module for generating resource.\n\n    Returns:\n        Base64 string of a generated resource image.\n    \"\"\"\n    # Get image from resource image creator\n    resource_image_generator = importlib.import_module(module_path)\n    image = resource_image_generator.resource_image(get_request, resource)\n\n    # Resize image to reduce file size\n    if get_request[\"paper_size\"] == \"a4\":\n        max_pixel_height = 267 * MM_TO_PIXEL_RATIO\n    elif get_request[\"paper_size\"] == \"letter\":\n        max_pixel_height = 249 * MM_TO_PIXEL_RATIO\n    (width, height) = image.size\n    if height > max_pixel_height:\n        ratio = max_pixel_height / height\n        width *= ratio\n        height *= ratio\n        image = image.resize((int(width), int(height)), Image.ANTIALIAS)\n\n    # Save image to buffer\n    image_buffer = BytesIO()\n    image.save(image_buffer, format=\"PNG\")\n\n    # Return base64 of image\n    return base64.b64encode(image_buffer.getvalue())\n", "path": "csunplugged/resources/views/generate_resource_pdf.py"}], "after_files": [{"content": "\"\"\"Module for generating custom resource PDFs.\"\"\"\n\nfrom django.http import HttpResponse\nfrom django.template.loader import render_to_string\nfrom django.contrib.staticfiles import finders\nfrom django.conf import settings\nfrom PIL import Image\nfrom io import BytesIO\nimport importlib\nimport base64\n\nRESPONSE_CONTENT_DISPOSITION = 'attachment; filename=\"{filename}.pdf\"'\nMM_TO_PIXEL_RATIO = 3.78\n\n\ndef generate_resource_pdf(request, resource, module_path):\n    \"\"\"Return a response containing a generated PDF resource.\n\n    Args:\n        request: HTTP request object\n        resource: Object of resource data.\n        module_path: Path to module for generating resource.\n\n    Returns:\n        HTTP response containing generated resource PDF.\n    \"\"\"\n    # TODO: Weasyprint handling in production\n    import environ\n    env = environ.Env(\n        DJANGO_PRODUCTION=(bool),\n    )\n    if env(\"DJANGO_PRODUCTION\"):\n        return HttpResponse(\"<html><body>PDF generation is currently not supported in production.</body></html>\")\n    else:\n        from weasyprint import HTML, CSS\n        context = dict()\n        get_request = request.GET\n        context[\"paper_size\"] = get_request[\"paper_size\"]\n        context[\"resource\"] = resource\n        context[\"header_text\"] = get_request[\"header_text\"]\n\n        resource_image_generator = importlib.import_module(module_path)\n        filename = \"{} ({})\".format(resource.name, resource_image_generator.subtitle(get_request, resource))\n        context[\"filename\"] = filename\n\n        num_copies = range(0, int(get_request[\"copies\"]))\n        context[\"resource_images\"] = []\n        for copy in num_copies:\n            context[\"resource_images\"].append(\n                generate_resource_image(get_request, resource, module_path)\n            )\n\n        pdf_html = render_to_string(\"resources/base-resource-pdf.html\", context)\n        html = HTML(string=pdf_html, base_url=settings.STATIC_ROOT)\n        css_file = finders.find(\"css/print-resource-pdf.css\")\n        css_string = open(css_file, encoding=\"UTF-8\").read()\n        base_css = CSS(string=css_string)\n        pdf_file = html.write_pdf(stylesheets=[base_css])\n\n        response = HttpResponse(pdf_file, content_type=\"application/pdf\")\n        response[\"Content-Disposition\"] = RESPONSE_CONTENT_DISPOSITION.format(filename=filename)\n        return response\n\n\ndef generate_resource_image(get_request, resource, module_path):\n    \"\"\"Retrieve image(s) for one copy of resource from resource generator.\n\n    Images are resized to size.\n\n    Args:\n        get_request: HTTP request object\n        resource: Object of resource data.\n        module_path: Path to module for generating resource.\n\n    Returns:\n        List of Base64 strings of a generated resource images for one copy.\n    \"\"\"\n    # Get images from resource image creator\n    resource_image_generator = importlib.import_module(module_path)\n    raw_images = resource_image_generator.resource_image(get_request, resource)\n    if not isinstance(raw_images, list):\n        raw_images = [raw_images]\n\n    # Resize images to reduce file size\n    if get_request[\"paper_size\"] == \"a4\":\n        max_pixel_height = 267 * MM_TO_PIXEL_RATIO\n    elif get_request[\"paper_size\"] == \"letter\":\n        max_pixel_height = 249 * MM_TO_PIXEL_RATIO\n\n    images = []\n    for image in raw_images:\n        (width, height) = image.size\n        if height > max_pixel_height:\n            ratio = max_pixel_height / height\n            width *= ratio\n            height *= ratio\n            image = image.resize((int(width), int(height)), Image.ANTIALIAS)\n\n        # Save image to buffer\n        image_buffer = BytesIO()\n        image.save(image_buffer, format=\"PNG\")\n        # Add base64 of image to list of images\n        images.append(base64.b64encode(image_buffer.getvalue()))\n\n    return images\n", "path": "csunplugged/resources/views/generate_resource_pdf.py"}]}