display image through cgi python html

L

Ladislav Andel

Hi,
I'm trying to display image through my cgi script in HTML page
via <img src="image.cgi">

Can you give me an example, please?
What should be in the cgi script to display it?

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'

thanks,
Lada
 
M

Marc 'BlackJack' Rintsch

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.

Ciao,
Marc 'BlackJack' Rintsch
 
S

Steve Holden

Marc said:
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 -------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top