From 647c5ff0f3e8140f40d7f41f0874ce4e1f4df65c Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Mon, 8 Jun 2020 17:35:23 -0700 Subject: [PATCH] Fixed broken CSS on 404 page, closes #777 --- datasette/app.py | 11 ++++++++++- tests/test_html.py | 12 ++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/datasette/app.py b/datasette/app.py index a7c3c66afb..d562e6116e 100644 --- a/datasette/app.py +++ b/datasette/app.py @@ -1015,7 +1015,16 @@ async def handle_500(self, scope, receive, send, exception): templates = ["500.html"] if status != 500: templates = ["{}.html".format(status)] + templates - info.update({"ok": False, "error": message, "status": status, "title": title}) + info.update( + { + "ok": False, + "error": message, + "status": status, + "title": title, + "base_url": self.ds.config("base_url"), + "app_css_hash": self.ds.app_css_hash(), + } + ) headers = {} if self.ds.cors: headers["Access-Control-Allow-Origin"] = "*" diff --git a/tests/test_html.py b/tests/test_html.py index e6933dfe84..f9b18daa55 100644 --- a/tests/test_html.py +++ b/tests/test_html.py @@ -965,6 +965,18 @@ def inner_html(soup): return inner_html.strip() +@pytest.mark.parametrize("path", ["/404", "/fixtures/404"]) +def test_404(app_client, path): + response = app_client.get(path) + assert 404 == response.status + assert ( + '