Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > display image through cgi python html

Reply
Thread Tools

display image through cgi python html

 
 
Ladislav Andel
Guest
Posts: n/a
 
      07-24-2007
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



 
Reply With Quote
 
 
 
 
Marc 'BlackJack' Rintsch
Guest
Posts: n/a
 
      07-24-2007
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.

Ciao,
Marc 'BlackJack' Rintsch
 
Reply With Quote
 
 
 
 
Steve Holden
Guest
Posts: n/a
 
      07-24-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 -------------

 
Reply With Quote
 
Ladislav Andel
Guest
Posts: n/a
 
      07-24-2007
Thanks for quick reply.
Yes, that's the hint I needed.

Lada

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.
>
> Ciao,
> Marc 'BlackJack' Rintsch
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to pass value from one html to another html through python-cgi Monima Software 0 12-14-2010 10:36 AM
How to call an aspx that accepts parameters through HTTP POST and returns an image, and then display the image in my html? computer_guy ASP .Net 3 07-20-2007 04:25 AM
(Ab)using class CGI as non-CGI HTML generator? Josef 'Jupp' Schugt Ruby 3 03-06-2005 11:34 AM
CHtmlView: How to read html text before display, change and give to display changed html code? Marek Kurowski C Programming 1 08-18-2004 06:41 PM
myfile.cgi?image.gif saved as myfile.cgi in mozilla? joe Perl Misc 7 05-12-2004 10:50 AM



Advertisments