about summary refs log tree commit diff stats
path: root/create_report.py
blob: 6a95a146b047a3656ece6712ac1e95f92ed68d16 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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")