How do I serve an image from a python script?
piet at cs.uu.nl
piet at cs.uu.nl
Fri Jun 8 08:50:24 EDT 2001
>>>>> haaserd <haaserd at yahoo.com> (h) writes:
h> Hi,
h> I am trying to serve an image from a Python script using Apache under
h> Windows. My simple HTML statement:
h> <img src="ShowPict.py?fn=xxx" alt="a picture">
h> ...and my simple script:
h> #!c:/Python20/python.exe
h> import sys
h> def pix():
h> n = 'c:/My Pictures/Sample.jpg'
h> p = open(n,'rb')
h> apix = p.read()
h> p.close()
h> sys.stdout.write("content-type: image/jpeg\n\n")
import os, msvcrt
msvcrt.setmode(sys.stdout.fileno(),os.O_BINARY)
h> sys.stdout.write(apix)
h> sys.stdout.flush()
h> if __name__ == '__main__':
h> pix()
--
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.van.Oostrum at hccnet.nl
More information about the Python-list
mailing list