I\'m trying to create a dict within a list of dicts. How do I build the data structure and later to fetch the data via jinja2? Here is an example:
var = {
\
Not sure what do you mean by 'site' ...
The code below uses site as location on the file system. It iterates over the sites list and read the files for each site.
import os
import datetime
data = dict()
sites = ['.']
for site in sites:
data['listofiles'] = []
data['site'] = site
for f in os.listdir(site):
data['listofiles'].append(
{'time': str(datetime.datetime.fromtimestamp(os.path.getmtime(os.path.join(site, f)))), 'name': f})