From 1663a060d93f573f11fab1488a5181d20ebe6027 Mon Sep 17 00:00:00 2001 From: magmaus3 Date: Sun, 30 Oct 2022 12:55:24 +0100 Subject: [PATCH] Add convert_times function to jinja2 (useful, if you want to include times in templates) --- iwm_browser/main.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/iwm_browser/main.py b/iwm_browser/main.py index 45c561a..fad9176 100644 --- a/iwm_browser/main.py +++ b/iwm_browser/main.py @@ -8,14 +8,17 @@ import httpx import json import os import re +from . import utils basedir = os.path.dirname(__file__) app = FastAPI() app.mount("/static", StaticFiles(directory=basedir + "/static"), name="static") template_env = jinja2.Environment( - loader=jinja2.PackageLoader("iwm_browser", "templates"), - auto_reload=True - ) + loader=jinja2.PackageLoader("iwm_browser", "templates"), + auto_reload=True +) + +template_env.globals['convert_times'] = utils.convert_times BASE_URL = "http://make.fangam.es" THUMB_URL = "https://images.make.fangam.es"