from pathlib import Path def patch_flask_frozen(): try: import flask_frozen except ImportError: print("flask_frozen is not installed.") return init_path = Path(flask_frozen.__file__).parent / "__init__.py" if not init_path.exists(): print("Could not find flask_frozen __init__.py") return with open(init_path, "r") as f: lines = f.readlines() changed = False for i, line in enumerate(lines): if "url_encoding = self.app.url_map.charset" in line: lines[i] = " url_encoding = 'utf-8' # patched charset\n" changed = True if changed: with open(init_path, "w") as f: f.writelines(lines) print("✅ flask_frozen patched successfully.") else: print("⚠️ Patch already applied or target line not found.") if __name__ == "__main__": patch_flask_frozen()