mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
render_template: convert HTTPStatus objects
This will automate a lot of conversion that happens around the codebase in terms of status_code. As of this commit, we should improve usage and remove int(status_code) casts wherever we can. Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
7ae95ac908
commit
b7d67bf5fc
1 changed files with 2 additions and 2 deletions
|
@ -65,7 +65,7 @@ async def make_variable_context(request: Request, title: str, next: str = None):
|
|||
def render_template(request: Request,
|
||||
path: str,
|
||||
context: dict,
|
||||
status_code=int(HTTPStatus.OK)):
|
||||
status_code: HTTPStatus = HTTPStatus.OK):
|
||||
""" Render a Jinja2 multi-lingual template with some context. """
|
||||
|
||||
# Create a deep copy of our jinja2 environment. The environment in
|
||||
|
@ -81,7 +81,7 @@ def render_template(request: Request,
|
|||
template = templates.get_template(path)
|
||||
rendered = template.render(context)
|
||||
|
||||
response = HTMLResponse(rendered, status_code=status_code)
|
||||
response = HTMLResponse(rendered, status_code=int(status_code))
|
||||
response.set_cookie("AURLANG", context.get("language"))
|
||||
response.set_cookie("AURTZ", context.get("timezone"))
|
||||
return response
|
||||
|
|
Loading…
Add table
Reference in a new issue