We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Access media library from Challenge UI
Accessing the media library from the challenge UI is a useful idea if you're using images in the challenge interface. Saves some clicks. 

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `CTFd/admin/pages.py`
Content:
```
1 from flask import render_template, request
2 
3 from CTFd.admin import admin
4 from CTFd.models import Pages
5 from CTFd.schemas.pages import PageSchema
6 from CTFd.utils import markdown
7 from CTFd.utils.config.pages import build_html
8 from CTFd.utils.decorators import admins_only
9 
10 
11 @admin.route("/admin/pages")
12 @admins_only
13 def pages_listing():
14     pages = Pages.query.all()
15     return render_template("admin/pages.html", pages=pages)
16 
17 
18 @admin.route("/admin/pages/new")
19 @admins_only
20 def pages_new():
21     return render_template("admin/editor.html")
22 
23 
24 @admin.route("/admin/pages/preview", methods=["POST"])
25 @admins_only
26 def pages_preview():
27     data = request.form.to_dict()
28     schema = PageSchema()
29     page = schema.load(data)
30     return render_template("page.html", content=build_html(page.data["content"]))
31 
32 
33 @admin.route("/admin/pages/<int:page_id>")
34 @admins_only
35 def pages_detail(page_id):
36     page = Pages.query.filter_by(id=page_id).first_or_404()
37     page_op = request.args.get("operation")
38 
39     if request.method == "GET" and page_op == "preview":
40         return render_template("page.html", content=markdown(page.content))
41 
42     if request.method == "GET" and page_op == "create":
43         return render_template("admin/editor.html")
44 
45     return render_template("admin/editor.html", page=page)
46
```
--- 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/CTFd/admin/pages.py b/CTFd/admin/pages.py
--- a/CTFd/admin/pages.py
+++ b/CTFd/admin/pages.py
@@ -27,7 +27,7 @@
     data = request.form.to_dict()
     schema = PageSchema()
     page = schema.load(data)
-    return render_template("page.html", content=build_html(page.data["content"]))
+    return render_template("page.html", content=build_html(page.data.content))
 
 
 @admin.route("/admin/pages/<int:page_id>")

{"golden_diff": "diff --git a/CTFd/admin/pages.py b/CTFd/admin/pages.py\n--- a/CTFd/admin/pages.py\n+++ b/CTFd/admin/pages.py\n@@ -27,7 +27,7 @@\n     data = request.form.to_dict()\n     schema = PageSchema()\n     page = schema.load(data)\n-    return render_template(\"page.html\", content=build_html(page.data[\"content\"]))\n+    return render_template(\"page.html\", content=build_html(page.data.content))\n \n \n @admin.route(\"/admin/pages/<int:page_id>\")\n", "issue": "Access media library from Challenge UI\nAccessing the media library from the challenge UI is a useful idea if you're using images in the challenge interface. Saves some clicks. \n", "before_files": [{"content": "from flask import render_template, request\n\nfrom CTFd.admin import admin\nfrom CTFd.models import Pages\nfrom CTFd.schemas.pages import PageSchema\nfrom CTFd.utils import markdown\nfrom CTFd.utils.config.pages import build_html\nfrom CTFd.utils.decorators import admins_only\n\n\n@admin.route(\"/admin/pages\")\n@admins_only\ndef pages_listing():\n    pages = Pages.query.all()\n    return render_template(\"admin/pages.html\", pages=pages)\n\n\n@admin.route(\"/admin/pages/new\")\n@admins_only\ndef pages_new():\n    return render_template(\"admin/editor.html\")\n\n\n@admin.route(\"/admin/pages/preview\", methods=[\"POST\"])\n@admins_only\ndef pages_preview():\n    data = request.form.to_dict()\n    schema = PageSchema()\n    page = schema.load(data)\n    return render_template(\"page.html\", content=build_html(page.data[\"content\"]))\n\n\n@admin.route(\"/admin/pages/<int:page_id>\")\n@admins_only\ndef pages_detail(page_id):\n    page = Pages.query.filter_by(id=page_id).first_or_404()\n    page_op = request.args.get(\"operation\")\n\n    if request.method == \"GET\" and page_op == \"preview\":\n        return render_template(\"page.html\", content=markdown(page.content))\n\n    if request.method == \"GET\" and page_op == \"create\":\n        return render_template(\"admin/editor.html\")\n\n    return render_template(\"admin/editor.html\", page=page)\n", "path": "CTFd/admin/pages.py"}], "after_files": [{"content": "from flask import render_template, request\n\nfrom CTFd.admin import admin\nfrom CTFd.models import Pages\nfrom CTFd.schemas.pages import PageSchema\nfrom CTFd.utils import markdown\nfrom CTFd.utils.config.pages import build_html\nfrom CTFd.utils.decorators import admins_only\n\n\n@admin.route(\"/admin/pages\")\n@admins_only\ndef pages_listing():\n    pages = Pages.query.all()\n    return render_template(\"admin/pages.html\", pages=pages)\n\n\n@admin.route(\"/admin/pages/new\")\n@admins_only\ndef pages_new():\n    return render_template(\"admin/editor.html\")\n\n\n@admin.route(\"/admin/pages/preview\", methods=[\"POST\"])\n@admins_only\ndef pages_preview():\n    data = request.form.to_dict()\n    schema = PageSchema()\n    page = schema.load(data)\n    return render_template(\"page.html\", content=build_html(page.data.content))\n\n\n@admin.route(\"/admin/pages/<int:page_id>\")\n@admins_only\ndef pages_detail(page_id):\n    page = Pages.query.filter_by(id=page_id).first_or_404()\n    page_op = request.args.get(\"operation\")\n\n    if request.method == \"GET\" and page_op == \"preview\":\n        return render_template(\"page.html\", content=markdown(page.content))\n\n    if request.method == \"GET\" and page_op == \"create\":\n        return render_template(\"admin/editor.html\")\n\n    return render_template(\"admin/editor.html\", page=page)\n", "path": "CTFd/admin/pages.py"}]}