I do it all the time, but instead of writing to a stream directly, I write to file, and embed the image in the html. This works for me, because (1) I need that html around to let users setup options, and (2) the images are available at a later date - something that has been plotted once can be viewed multiple times.
You basically save your plot to a file and then include something like:
in your html.
Unless you serve thousands of requests, the few ms waisted writing/reading to/from a file should be negligible.
Finally, you might want to look into the error log file for apache, and see what goes on behind the scenes. I still run 0.65 (modified) and remember had to setup proper permissions on a cache file before thigs worked.
Another thing, maybe not the case here, but worth remembering that it is crucial to have the 'Content-type' line be the first data written. I've had issues in the past where importing some libraries would write something else to the stream, and often would be get some criptic errror.
Peter Groszkowski Gemini Observatory
Tel: +1 808 9742509 670 N. A'ohoku Place
Fax: +1 808 9359235 Hilo, Hawai'i 96720, USA
Simon Hook wrote:
The code below when run from a file in the cgi-bin directory should generate a plot but it does not work:
from pylab import *
#print "Content-type: text/html\n\n"
#print "<html>Hello world!</html>"
print "Content-type: image/png\n\n"
However, it does not work and I am really struggling to get matplotlib to generate a plot dynamically in a cgi-script. If anyone has done this successfully I would really appreciate some help or a simple example. I am using Windows XP and Apache 2.0.53.
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
Matplotlib-users mailing list