Python cgi script - outputting images
Roman Suzi
rnd at onego.ru
Sun Jul 1 12:17:44 EDT 2001
On Sun, 1 Jul 2001, Mexican Bandit wrote:
>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()
# Maybe:
import sys, urllib
sys.stdout.write("Content-Type: image/jpeg\n\n")
sys.stdout.write(urllib.urlopen("http://127.0.0.1/splogo.jpg").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?
>
>
Sincerely yours, Roman Suzi
--
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
_/ Sunday, July 01, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ "DEVICE=EXXON.SYS may mess up your environment" _/
More information about the Python-list
mailing list