display image through cgi python html

Steve Holden steve at holdenweb.com
Tue Jul 24 07:17:07 EDT 2007


Marc 'BlackJack' Rintsch wrote:
> On Tue, 24 Jul 2007 11:58:47 +0200, Ladislav Andel wrote:
> 
>> Here is what I have in image.cgi but it is incorrect and i'm not able to 
>> find it on the web.
>>
>> #!/usr/bin/python
>> print "Content-Type: image/png\n"
>> print 'image.png'
> 
> You have to print the image, not the name.  Read the binary file and print
> it.
> 
As in:

#!/usr/bin/python
data = open('image.png', 'rb').read()
print "Content-Type: image/png\nContent-Length: %d\n" % len(data)
print data

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd           http://www.holdenweb.com
Skype: holdenweb      http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------




More information about the Python-list mailing list