CGI -- generating images -- \x0A always added!
bokr at oz.net
Wed Sep 10 06:32:38 CEST 2003
On Wed, 10 Sep 2003 03:05:51 GMT, "M-a-S" <NO-MAIL at hotmail.com> wrote:
>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:
I would try switching to using sys.stdout.write
>img = open( 'a.gif', 'rb' ) # OK, don't make the image, just use the file
> data = img.read()
>print "Content-type: image/gif"
The above two might work ok, but might as well use
sys.stdout.write consistently instead, e.g.,
# untested ...
sys.stdout.write('Content-type: image/gif\n\n') # should be the same
>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.
HTH. It should be easy to try. Let us know.
More information about the Python-list