More comments in code

This commit is contained in:
DarkCat09 2023-02-27 19:05:04 +04:00
parent 3698d46649
commit 1d9fa011a3
6 changed files with 32 additions and 2 deletions

View file

@ -20,6 +20,7 @@ class ErrorsPaths(Paths):
def add_paths(self) -> None:
# For each HTTP code specified above
for code in codes:
self.add_handler(code)
@ -31,14 +32,19 @@ class ErrorsPaths(Paths):
code (int): HTTP error code
"""
# Jinja template file name
# e.g. 404.html for 404 code
file = Path(common.templates_dir) / f'{code}.html'
# Exit from the function
# if the template does not exist
if not file.exists():
return
@self.app.exception_handler(code)
async def handler(req: Request, exc: HTTPException) -> Response:
# Respond with the template
return respond.with_tmpl(
f'{code}.html',
code=code,