问题
I'm new to using python and flask and really like it. I'm returning a query to be displayed in a jinja template and one of my columns being returned has base64 data. How do I decode that data and display it.
回答1:
In jinja To work with Base64 encoded strings:
{{ encoded | b64decode }}
{{ decoded | b64encode }}
For more http://docs.ansible.com/ansible/playbooks_filters.html
回答2:
You can try to write custom filter
# add filter to jinja2 env
environment.filters['b64decode'] = base64.b64decode
# in template use
{{ value|b64decode }}
来源:https://stackoverflow.com/questions/39047657/base64-decode-string-in-jinja