CGI Proplem displaying image

matthiasjanes matthiasjanes at gmx.net
Fri May 7 23:37:58 EDT 2004


Hi,
Maybe someone of you can help me.

I'm trying to display an image in memory(open file) with an cgi script
- but it want work proberly:

I'm running an Cgi webserver (CgiServerGui.py).

both files are in the /cgi/ folder

#################
#my CGISRIPT: test.py

#! /usr/bin/env python

print ("Content-type: image/jpeg");
print # End of headers!

filename="cgi-bin//dog.jpg"
infile = open(filename, 'rb')
doginmemory=infile.read()
print doginmemory

##################

#################
#my html page with the image tag

<html>
<head>
</head>
<body>
<img type="image" src="/cgi-bin/test.py" height="25" width="111">
</body>
</html>

################


I can't figure out whats the problem.

funny: if I use a form with an method='post' I can get the picture
show up in a whole webpage ( method='get' will not work)

###########
<html>
<head>
</head>
<body>
<form name="test" method="post" action="/cgi-bin/test.py">
<input type="submit" value="go">
</body>
</html>
############


Any suggestion: (by the way: in the end the whole pictures should be
stored in an sqlite database and also retrieved from it to be
displayed within an html page.


Thanks  Matthias



More information about the Python-list mailing list