sio = StringIO.StringIO()
plt.savefig(sio, format='png')
img_b64 = sio.getvalue().encode('base64').strip()
plt.clf()
sio.close()
self.response.write('<html><body>')
self.response.write("<img src='data:image/png;base64,%s'/>" % img_b64)
self.response.write('</body> </html>')
app = webapp2.WSGIApplication([('/', MainPage)], debug=True)
Using matplotlib in GAE