Python cgi script - outputting images

Mexican Bandit eli-wallach at ugly.com
Sun Jul 1 11:37:35 EDT 2001


Hi,

Wondering of anyone can help - Python newbie. I'm trying to write a
Python cgi script which outputs a gif or jpg image from another
server...

----
import urllib

print "Content-Type: image/jpeg"
print

image = urllib.urlopen("http://127.0.0.1/splogo.jpg")
print image.read()
----

The output of the image is corrupted. I suspect this is to do with
'print' turning everything into strings?

How do I output raw image data?




More information about the Python-list mailing list