Files
hydrogen/jinja_env.py
SG ed9d1dade2 added script path detection
prepare for PyInstaller
2025-06-14 17:37:33 +03:00

17 lines
604 B
Python

import sys
from pathlib import Path
from jinja2 import Environment, FileSystemLoader
from config import Config
# Prepare template rendering engine
if getattr(sys, 'frozen', False):
# Running fron Pyinstaller-packed binary
base_dir = Path(sys._MEIPASS)
else:
# Running as a plain Python app
base_dir = Path(__file__).resolve().parent
env = Environment(loader=FileSystemLoader(f"{base_dir}/{Config.TEMPLATES_DIR}"))
env.globals['header_image'] = Config.HEADER_IMAGE
index_template = env.get_template("index.html")
content_item_template = env.get_template("content_item.html")