from jinja2 import Environment, FileSystemLoader # Load the template from the current directory env = Environment(loader=FileSystemLoader('.')) template = env.get_template("template.html") # Data to be passed into the template data = { "title": "My Report", "items": ["Apple", "Banana", "Cherry"] } data["items"].append("hello") # Render the template with data html_output = template.render(data) # Save the generated HTML to a file with open("report.html", "w", encoding="utf-8") as f: f.write(html_output) print("Report generated: report.html")