def data_prettified(instance):
"""Function to display pretty version of our data"""
# Convert the data to sorted, indented JSON
response = json.dumps(instance, sort_keys=True, indent=2)
# Truncate the data. Alter as needed
#response = response[:5000]
# Get the Pygments formatter
formatter = HtmlFormatter(style='colorful')
# Highlight the data
response = highlight(response, JsonLexer(), formatter)
# Get the stylesheet
style = "<style>" + formatter.get_style_defs() + "</style><br>"
# Safe the output
return mark_safe(style + response)
评论列表
文章目录