CGI -- generating images -- \x0A always added!

M-a-S NO-MAIL at hotmail.com
Wed Sep 10 05:05:51 CEST 2003


Hi All,

I'm trying to use Python for generating (or copying) images.
The environment is Python 2.3/Apache 2.0.43/Windows XP.
I couldn't make Apache use mod_python (anybody can help?
Apache complains "The requested operation has failed"
if I add LoadModule python_module modules/mod_python.so)
so I use the CGI mechanism. This is the sample:

#!C:\Apps\Python\python.exe -u

img = open( 'a.gif', 'rb' ) # OK, don't make the image, just use the file
if img:
  data = img.read()
  img.close()

print "Content-type: image/gif"
print

print data,

# EOF

Everything's good, and '-u' helps not to add '\x0D' for each '\x0A'
inside the data. BUT it seems that the last print ALWAYS adds LF
'\x0A' in spite of the final comma. How can I fix that? Thank you.

M-a-S






More information about the Python-list mailing list