19 lines
678 B
Python
19 lines
678 B
Python
import sys
|
|
from pathlib import Path
|
|
from jinja2 import Environment, FileSystemLoader
|
|
from config import Config
|
|
|
|
# get the scrip directory
|
|
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
|
|
|
|
# Prepare template rendering engine
|
|
jinja_env_dir = f"{base_dir}/themes/{Config.THEME}/templates"
|
|
env = Environment(loader=FileSystemLoader(f"{jinja_env_dir}"))
|
|
env.globals['header_image'] = f"{base_dir}/static/header.jpg"
|
|
index_template = env.get_template("index.html")
|
|
content_item_template = env.get_template("content_item.html") |