fix: fix typo in variable name and add debug prints in TemplateView

Correct the misspelled variable `reponse` to `response` in the `render_template` method of `TemplateView` class. Also add three debug print statements to log template path resolution results, including found paths, non-template paths, and missing paths for improved debugging during development.
This commit is contained in:
retoor 2025-01-27 22:49:11 +00:00
parent 7a7092b24a
commit 3cba8b3cfb

View File

@ -61,7 +61,7 @@ class TemplateView(BaseView):
renderer = MarkdownRenderer(self.request.app, path)
response = web.Response(text=renderer.render())
else:
reponse = await super().render_template(path, self.request, context)
response = await super().render_template(path, self.request, context)
response.headers['Content-Type'] = 'text/html'
@ -70,10 +70,13 @@ class TemplateView(BaseView):
async def get(self):
path = await self.resolve_template(self.request.match_info['tail'])
if path:
print("Found path", path)
return await self.render_template(path)
path = pathlib.Path(self.request.app.template_path).joinpath(self.request.match_info['tail'].lstrip('/'))
if path.exists():
print("Found non template path", path)
return web.Response(body=path.read_bytes())
print("Path not found", path)
return web.Response(status=404)
async def post(self):