I am not sure what I am doing wrong, It would be great if you could point me toward what to read. I have taken the first CherryPy tutorial "hello world" added a little matplotlib plot. Question 1: how do I know where the file will be saved? It happens to be where I am running the file. Question 2: I don't seem to be get the image to open/view in my browser. When I view source in the browser everything looks right but no luck, even when I am including the full image path. I think my problem is with the path but not sure the mechanics of what is happening
thanks for the help Vincent
import cherrypy
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
class HelloWorld:
def index(self):
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot([1,2,3])
fig.savefig('test.png')
return ''' <img src="test.png" width="640" height="480" border="0" /> '''
index.exposed = True
import os.path
tutconf = os.path.join(os.path.dirname(__file__), 'tutorial.conf')
if __name__ == '__main__':
cherrypy.quickstart(HelloWorld(), config=tutconf)
else:
cherrypy.tree.mount(HelloWorld(), config=tutconf)