Commit 534b4bef authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Add the base64 string encoding for pdf and png graphic files.

parent 4ff4859e
......@@ -2,6 +2,7 @@
""" Controllers for building graphs using pandas library
"""
import base64
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
......@@ -90,4 +91,9 @@ def index():
extension = request.extension
fmt = "svg" if extension == "html" else extension
return dict(data=savefig(ax.get_figure(), fmt))
# base64 string encoding
data = savefig(ax.get_figure(), fmt)
if fmt in ("pdf", "png"):
data = base64.b64encode(data)
return dict(data=data)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment