From d51a5089f5450eb1261130ca9e9f569ce96c11d9 Mon Sep 17 00:00:00 2001 From: southerntofu Date: Wed, 28 Jul 2021 19:43:33 -0400 Subject: [PATCH] Don't traceback when favicon.ico is requested, display a nice error instead --- main.py | 7 +++++++ templates/error.html | 8 ++++++++ 2 files changed, 15 insertions(+) create mode 100644 templates/error.html diff --git a/main.py b/main.py index 8f9961c..2d884a1 100644 --- a/main.py +++ b/main.py @@ -149,6 +149,13 @@ 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 return redirect("/" + domain + "/videos/trending") @app.route("//videos/local", defaults = {"page": 1}) diff --git a/templates/error.html b/templates/error.html new file mode 100644 index 0000000..7d8f4c5 --- /dev/null +++ b/templates/error.html @@ -0,0 +1,8 @@ +{% extends "base.html" %} + +{% block title %}ERROR: {% endblock %} + +{% block content %} +

Error {{ error_number }}

+

{{ error_reason }}

+{% endblock %}