user3440716
user3440716

Reputation: 649

How to display image in Python-cgi

I am beginner and i dont know where i am doing mistake. i have seen these stack posts Return an image to the browser in python, cgi-bin , Return Image from python CGI using javascript and How to loading/show a picture in a Python CGI page but got no help.

Here is the code:

#!C:\Python27\python

text = """Content-type: text/html\n

<TITLE> CGI 101 </TITLE>
<H1>A SECOND CGI SCRIPT </H1>
<HR>
<P> HELLO,CGI WORLD!</P>
<img src="../imag000.jpg" width=101 height=64 border=0 alt="">
<HR>
"""

print (text)

and on browser it appears small box which is not showing image, like this:

enter image description here

Kindly help.

and folder which contains image is cgi. Kindly see picture:

enter image description here

Upvotes: 3

Views: 3580

Answers (2)

user3440716
user3440716

Reputation: 649

Here is the best Solution:

<img src="http://localhost/imag000.jpg" width=101 height=64 border=0 alt="">

Upvotes: 2

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799510

The HTML claims that the image is in the parent directory, but the server has it in the same directory. Either modify the HTML to match the current image location, or move the image to where the browser is requesting it from.

Upvotes: 0

Related Questions