From a88e73804c1dc18cd5c1d7e0fa603d206d2a2a05 Mon Sep 17 00:00:00 2001 From: Eva Date: Thu, 21 Mar 2024 01:05:55 +0100 Subject: [PATCH] server/embed: return html on index error --- server/szurubooru/api/__init__.py | 2 +- server/szurubooru/api/{oembed_api.py => embed_api.py} | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) rename server/szurubooru/api/{oembed_api.py => embed_api.py} (96%) diff --git a/server/szurubooru/api/__init__.py b/server/szurubooru/api/__init__.py index f6b8973a..854c50cb 100644 --- a/server/szurubooru/api/__init__.py +++ b/server/szurubooru/api/__init__.py @@ -1,6 +1,6 @@ import szurubooru.api.comment_api +import szurubooru.api.embed_api import szurubooru.api.info_api -import szurubooru.api.oembed_api import szurubooru.api.password_reset_api import szurubooru.api.pool_api import szurubooru.api.pool_category_api diff --git a/server/szurubooru/api/oembed_api.py b/server/szurubooru/api/embed_api.py similarity index 96% rename from server/szurubooru/api/oembed_api.py rename to server/szurubooru/api/embed_api.py index cfc9046c..dbead402 100644 --- a/server/szurubooru/api/oembed_api.py +++ b/server/szurubooru/api/embed_api.py @@ -78,7 +78,11 @@ def get_post( @rest.routes.get("/index(?P/.+)") def post_index(ctx: rest.Context, params: Dict[str, str]) -> rest.Response: path = _index_path(params) - oembed = get_post(ctx, {}, path) + try: + oembed = get_post(ctx, {}, path) + except posts.PostNotFoundError: + return {"return_type": "custom", "content": index_html} + url = config.config["site_url"] + path new_html = index_html.replace("", f'''