2π
β
the easiest approach would be translate your python object to JSON first.
then use one of many json to html converter.
EX:
https://github.com/bloopletech/json2html/tree/master
demo
http://json.bloople.net/#_output
because your python object include datetime type, the json decoder need to be extended first.
import json
def extend_json(obj):
if isinstance(obj, date):
return str(obj)
elif isinstance(obj, datetime):
return obj.strftime("%Y-%m-%d %H:%M:%S")
elif isinstance(obj, Decimal):
return float(obj)
data = json.dumps(obj, indent=4, sort_keys=True, default=extend_json)
π€lucemia
Source:stackexchange.com