import os import glob pwa_tags = """ """ templates_dir = os.path.join(os.path.dirname(__file__), 'templates') for filepath in glob.glob(os.path.join(templates_dir, '*.html')): with open(filepath, 'r', encoding='utf-8') as f: content = f.read() # Only replace if not already added if "rel=\"manifest\"" not in content and "" in content: content = content.replace("", pwa_tags) with open(filepath, 'w', encoding='utf-8') as f: f.write(content) print(f"Patched {os.path.basename(filepath)}")