Answer the question
In order to leave comments, you need to log in
How to display a dictionary in Jinja2?
I'm trying to output the collected dictionary to the Jinja template, but it doesn't work.
the dictionary contains {'nginx': 'running', 'mysql': 'not running'}
@asyncio.coroutine
def handle(request):
context = {}
for daemon in service:
status = subprocess.call('service %s status' %daemon,
shell=True,
stdout=open('/dev/null', 'w'),
stderr=subprocess.STDOUT
)
tt = {daemon: commands[status]}
context.update(tt)
return aiohttp_jinja2.render_template('index.html', request, context)
{{ context.items() }}
jinja2.exceptions.UndefinedError: 'context' is undefined
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question