from jinja2 import Template from os.path import join import json import codecs def do(): data = json.load(open("chronoPrint.json")) i = 1 for d in data: d['serial'] = i i += 1 t = Template(open("template.html").read()) s = t.render({'files': data}) out = codecs.open("out.html", "w", encoding="utf-8") out.write(s) out.close()