Apache/Win 95 Irregularity

Fredrik Lundh fredrik at pythonware.com
Mon Apr 16 12:31:26 EDT 2001


Steve Holden wrote:
> Under Windows 95 using Apache/1.3.19 and ActivePython (original build) I get
> something which IE 5.5 reports as being a 2326-byte GIF file containing a
> 259 x 32-pixel image whose appearance bears no relation to the Apache logo:

    http://www.python.org/doc/FAQ.html#7.12
    Q. cgi.py (or other CGI programming) doesn't work
    sometimes on NT or win95!

summary: the output stream is opened in text mode under Windows.  to get
binary mode, run the interpreter with the -u option.

> #!C:\Python20\python

this might work:

    #!C:\Python20\python -u

> ##
> ##  image.py: serve a GIF image
> ##
> import sys, base64
> o = open("C:/Program Files/Apache
> Group/Apache/htdocs/apache_pb.gif","rb").read()
> sys.stdout.write('Content-Type: image/gif\r\n')
> sys.stdout.write('Content-Length: %d\r\n\r\n' % len(o))
> sys.stdout.write(o)

Cheers /F





More information about the Python-list mailing list