You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Simon Hook <si...@jpl.nasa.gov> on 2005/03/19 02:49:28 UTC
[users@httpd] Apache 2.0.53 will not display png from 4 line python script
Hi,
I have a 4 line python script which should display a png that is in the
same directory as the script. The script is:
#!d:/apps/Python23/python.exe
fp = open('tmp.png','rb')
print "Content-type: image/png\n"
print fp.read()
fp.close()
However all the script generates is:
The image “http://shook-m2/cgi-bin/plot.py” cannot be displayed, because
it contains errors.
plot.py is the name of the script.
I am using:
Python 2.3 (Enthought version)
Apache 2.0.53
Windows XP Sp2
The script is in cgi-bin. Other python scripts work fine e.g. hello world.
Any ideas would be much appreciated.
Thanks, Simon
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Apache 2.0.53 will not display png from 4 line python script
Posted by André Malo <nd...@perlig.de>.
* Simon Hook wrote:
> Your solution does not work. If you have something you have tested and
> works, please send.
uh, it clearly wasn't a solution. It was food for thought :-)
So what does "does not work" mean? Exactly?
nd
--
Da fällt mir ein, wieso gibt es eigentlich in Unicode kein
"i" mit einem Herzchen als Tüpfelchen? Das wär sooo süüss!
-- Björn Höhrmann in darw
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Apache 2.0.53 will not display png from 4 line
python script - IT WORKS
Posted by Simon Hook <si...@jpl.nasa.gov>.
Andre/Joshua,
If I remove the "\n" it works. Thanks to both of you. I have struggled
for a long time with this.
Simon
André Malo wrote:
>* Joshua Slive wrote:
>
>
>
>>It is possible that the problem with Andre's script is the extra "\n",
>>since "print" adds one itself, I believe.
>>
>>
>
>uh, yeah, forgot about that. I'm using print not that much :)
>
>nd
>
>
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Apache 2.0.53 will not display png from 4 line python script
Posted by André Malo <nd...@perlig.de>.
* Joshua Slive wrote:
> It is possible that the problem with Andre's script is the extra "\n",
> since "print" adds one itself, I believe.
uh, yeah, forgot about that. I'm using print not that much :)
nd
--
Gib' mal folgendes in die Kommandozeile ein (und einen Moment warten):
net send localhost "Buuuh!"
Na, erschreckt? -- Markus Becker in mpdsh
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Apache 2.0.53 will not display png from 4 line python script
Posted by Joshua Slive <js...@gmail.com>.
On Sat, 19 Mar 2005 10:14:34 -0800, Simon Hook
<si...@jpl.nasa.gov> wrote:
> Andre,
>
> Your solution does not work. If you have something you have tested and
> works, please send.
How about you contribute a little yourself by comparing the output to
the original file and seeing where they differ?
It is possible that the problem with Andre's script is the extra "\n",
since "print" adds one itself, I believe.
Joshua.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Apache 2.0.53 will not display png from 4 line
python script
Posted by Simon Hook <si...@jpl.nasa.gov>.
Andre,
Your solution does not work. If you have something you have tested and
works, please send.
thanks,
Simon
André Malo wrote:
>* Simon Hook wrote:
>
>
>
>>I have a 4 line python script which should display a png that is in the
>>same directory as the script. The script is:
>>
>>#!d:/apps/Python23/python.exe
>>
>>fp = open('tmp.png','rb')
>>print "Content-type: image/png\n"
>>print fp.read()
>>fp.close()
>>
>>Any ideas would be much appreciated.
>>
>>
>
>(1) Missing an empty line between the headers and the body
>(2) Never use print with binary data
>(3) Use binary mode on stdout on Win32 systems when working with binary data
>
>#!d:/apps/Python23/python.exe
>
>import os, sys, msvcrt
>
>fp = open('tmp.png', 'rb')
>print "Content-type: image/png\n\n"
>msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
>sys.stdout.write(fp.read())
>fp.close()
>
>(untested)
>
>nd
>
>
--
+++++++++++++++++++++++++++++++++++++++++
Simon J. Hook, MSc, PhD
Jet Propulsion Laboratory
MS 183-501
Pasadena, CA 91109
Office: 818-354-0974
Fax: 818-354-0966
Email: simon.j.hook@jpl.nasa.gov
http://asterweb.jpl.nasa.gov
http://masterweb.jpl.nasa.gov
http://laketahoe.jpl.nasa.gov
+++++++++++++++++++++++++++++++++++++++++
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Apache 2.0.53 will not display png from 4 line python script
Posted by André Malo <nd...@perlig.de>.
* Simon Hook wrote:
> I have a 4 line python script which should display a png that is in the
> same directory as the script. The script is:
>
> #!d:/apps/Python23/python.exe
>
> fp = open('tmp.png','rb')
> print "Content-type: image/png\n"
> print fp.read()
> fp.close()
>
> Any ideas would be much appreciated.
(1) Missing an empty line between the headers and the body
(2) Never use print with binary data
(3) Use binary mode on stdout on Win32 systems when working with binary data
#!d:/apps/Python23/python.exe
import os, sys, msvcrt
fp = open('tmp.png', 'rb')
print "Content-type: image/png\n\n"
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
sys.stdout.write(fp.read())
fp.close()
(untested)
nd
--
"Solides und umfangreiches Buch"
-- aus einer Rezension
<http://pub.perlig.de/books.html#apache2>
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org