From 404b6e73f62c5a8aeef98753bcdc7da1b11803c0 Mon Sep 17 00:00:00 2001 From: southerntofu Date: Wed, 28 Jul 2021 19:43:35 -0400 Subject: [PATCH] Also serve /favicon.ico directly as 404 to avoid pointless requests --- main.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 79a8337..ac3fa1e 100644 --- a/main.py +++ b/main.py @@ -157,12 +157,7 @@ async def simpleer_search(query, page): @app.route("//") async def instance(domain): # favicon.ico is not a domain name - if domain == "favicon.ico": - return await render_template( - "error.html", - error_number = "404", - error_reason = "We don't have a favicon yet. If you would like to contribute one, please send it to ~metalune/public-inbox@lists.sr.ht" - ), 404 + if domain == "favicon.ico": return await favicon() return redirect("/" + domain + "/videos/trending") @app.route("//videos/local", defaults = {"page": 1}) @@ -430,6 +425,15 @@ async def subtitles(domain, id, lang): error_reason = e ), 500 +# --- Favicon --- +@app.route("/favicon.ico") +async def favicon(): + return await render_template( + "error.html", + error_number = "404", + error_reason = "We don't have a favicon yet. If you would like to contribute one, please send it to ~metalune/public-inbox@lists.sr.ht" + ), 404 + if __name__ == "__main__": if len(sys.argv) == 3: interface = sys.argv[1]