Skip to content

Commit

Permalink
Fixed broken CSS on 404 page, closes #777
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Jun 9, 2020
1 parent 49d6d2f commit 647c5ff
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
11 changes: 10 additions & 1 deletion datasette/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"] = "*"
Expand Down
12 changes: 12 additions & 0 deletions tests/test_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
'<link rel="stylesheet" href="/-/static/app.css?{}'.format(
app_client.ds.app_css_hash()
)
in response.text
)


@pytest.mark.parametrize(
"path,expected_redirect",
[("/fixtures/", "/fixtures"), ("/fixtures/simple_view/", "/fixtures/simple_view")],
Expand Down

0 comments on commit 647c5ff

Please sign in to comment.