httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Malo>
Subject Re: [users@httpd] Apache 2.0.53 will not display png from 4 line python script
Date Sat, 19 Mar 2005 09:24:03 GMT
* 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.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


import os, sys, msvcrt

fp = open('tmp.png', 'rb')
print "Content-type: image/png\n\n"
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)


"Solides und umfangreiches Buch"
                                          -- aus einer Rezension


The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message