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")