From 8a366ef7f4f3306761fc163071f74766a51e1292 Mon Sep 17 00:00:00 2001 From: Robert Christie Date: Tue, 1 Feb 2022 17:15:18 +0000 Subject: [PATCH 1/2] Ensure template_path always uses "/" to match jina --- datasette/app.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/datasette/app.py b/datasette/app.py index 09d7d0342b..5b6d71b327 100644 --- a/datasette/app.py +++ b/datasette/app.py @@ -1212,7 +1212,8 @@ async def handle_404(self, request, send, exception=None): else: # Is there a pages/* template matching this path? route_path = request.scope.get("route_path", request.scope["path"]) - template_path = os.path.join("pages", *route_path.split("/")) + ".html" + # Ensure template_path always uses "/" to match jina + template_path = "pages" + route_path + ".html" try: template = self.ds.jinja_env.select_template([template_path]) except TemplateNotFound: From af293c960e67b14ebd8ec7517b698803606fae96 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Wed, 2 Feb 2022 17:30:25 -0800 Subject: [PATCH 2/2] Changed variable name and comment --- datasette/app.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/datasette/app.py b/datasette/app.py index 5b6d71b327..7bdf076c7f 100644 --- a/datasette/app.py +++ b/datasette/app.py @@ -1212,10 +1212,10 @@ async def handle_404(self, request, send, exception=None): else: # Is there a pages/* template matching this path? route_path = request.scope.get("route_path", request.scope["path"]) - # Ensure template_path always uses "/" to match jina - template_path = "pages" + route_path + ".html" + # Jinja requires template names to use "/" even on Windows + template_name = "pages" + route_path + ".html" try: - template = self.ds.jinja_env.select_template([template_path]) + template = self.ds.jinja_env.select_template([template_name]) except TemplateNotFound: template = None if template is None: