More comments in code
This commit is contained in:
parent
3698d46649
commit
1d9fa011a3
6 changed files with 32 additions and 2 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue