From df4801ff4e723a9298f40a7415cc454a0d64129e Mon Sep 17 00:00:00 2001 From: Guy Korland Date: Sun, 24 Aug 2025 20:59:54 +0300 Subject: [PATCH 1/2] add tempalte caching --- api/routes/auth.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/routes/auth.py b/api/routes/auth.py index f7c1d358..06751f7b 100644 --- a/api/routes/auth.py +++ b/api/routes/auth.py @@ -12,7 +12,7 @@ from fastapi.templating import Jinja2Templates from authlib.common.errors import AuthlibBaseError from authlib.integrations.starlette_client import OAuth -from jinja2 import Environment, FileSystemLoader, FileSystemBytecodeCache +from jinja2 import Environment, FileSystemLoader, FileSystemBytecodeCache, select_autoescape from starlette.config import Config from api.auth.user_management import validate_and_cache_user @@ -31,7 +31,8 @@ directory=TEMPLATES_CACHE_DIR, pattern="%s.cache" ), - auto_reload=True + auto_reload=True, + autoescape=select_autoescape(['html', 'xml', 'j2']) ) ) From 845eb6837946e62db3a0a853d1c6bce42c274bd7 Mon Sep 17 00:00:00 2001 From: Guy Korland Date: Sun, 24 Aug 2025 21:20:20 +0300 Subject: [PATCH 2/2] change to temp folder --- api/routes/auth.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/routes/auth.py b/api/routes/auth.py index 06751f7b..d8225885 100644 --- a/api/routes/auth.py +++ b/api/routes/auth.py @@ -21,7 +21,7 @@ auth_router = APIRouter() TEMPLATES_DIR = str((Path(__file__).resolve().parents[1] / "../app/templates").resolve()) -TEMPLATES_CACHE_DIR = "./.jinja_cache" +TEMPLATES_CACHE_DIR = "/tmp/jinja_cache" os.makedirs(TEMPLATES_CACHE_DIR, exist_ok=True) # ✅ ensures the folder exists templates = Jinja2Templates(