Image serving using python

jzalesky at my-deja.com jzalesky at my-deja.com
Wed Oct 4 20:50:44 EDT 2000


I'm trying to use python scripts to serve images on a web server using
the cgi library interface.  The python script is of the form:

"http://server/directory/getimage.py?imgid=61"

After opening and getting the image into a string variable
called 'pic', I
call the following function:

def output_picture(pic)
    print "Accept-Ranges: bytes"
    print "Content-Length: ", len(pic)
    print "Connection: close"
    print "Content-Type: image/gif"
    print

    sys.stdout.write(pic)

I know that the picture in 'pic' is correct because 'len(pic)' returns
the correct length of the file and I've checked its contents against
the original file.  However the browser does not seem to be displaying
it at all.

Does anyone know what I might be doing wrong?  If so, let me know.  Or
if anyone knows of another way to do this, please let me know.

Thanks.

Jon


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list