|
From: Steve C. <sc...@ja...> - 2009-11-16 15:53:08
|
OK, I feel like an idiot but I guess I'm really not understanding you
even after reading the document you referred me to. The specific words
I'm not understanding are "going separate ways".
To that end I've gone back to basics and rewritten the example on p. 241
in python. I believe my translation is more or less exact:
================================
#!/usr/bin/python
import os
import math
print "Content-Type: image/png" # This is an image
print # blank line, end of headers
gp = os.popen("/usr/bin/gnuplot", 'w')
gp.write("set term png;set o;")
gp.write("plot '-' u 1:2 w linesp\n")
xs = [a/10.0 for a in range(0,101,1)]
for x in xs:
y = x * math.sin(x)
gp.write( "%f %f\n" % (x, y))
gp.write("e\n")
gp.close()
=================================
This fails with the following message
[error] [client ::1] malformed header from script. Bad header=\x89PNG:
whether or not the gp.close() line is commented out.
What am I missing?
Thomas Sefzick wrote:
> seems that your header:
>
> print "Content-Type: image/png" # This is an image
> print # blank line, end of headers
>
> and gnuplots output (png graphics) are going different
> ways, because the png graphics is sent without header
> (a png file starts with "\x89PNG").
>
> have a look at the section "Object Headers" in
> http://marc.merlins.org/htmlearn/misc/cgi-faq.txt
>
>
> stevecoh1 wrote:
>> Here's the error:
>>
>> [error] [client ::1] malformed header from script. Bad header=\x89PNG:
>> usage_graph.cgi
>>
...
|