Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure template_path always uses "/" to match jinja #1617

Merged
merged 2 commits into from
Feb 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions datasette/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1212,9 +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"])
template_path = os.path.join("pages", *route_path.split("/")) + ".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:
Expand Down