Read an image from a URL and write it to the browser

McCoy Fan robert.panesse at gmail.com
Sun Dec 21 12:29:29 CET 2008



I want to do something simple: read an image from an image URL and
write the image to the browser in CGI style.

I wrote a CGI script to do this (I'm new to Python) and got the
following error:

"FancyURLopener instance has no attribute 'tempcache'" in <bound
method FancyURLopener.__del__ of <urllib.FancyURLopener instance

I have no idea what that error means and neither does Google.

Any idea where I went wrong in the code below?



import urllib

urlString = "http://www.google.com/google_logo.jpg"
imgStream = urllib.urlopen(urlString)
imgBuffer = imgStream.read()
imgStream.close()
print "Content-Type: image/jpeg"
print
print imgBuffer



More information about the Python-list mailing list