CGI Proplem displaying image

Karl Casavant shekmalhen at NO.SPAMfastmail.fm
Sat May 8 15:57:33 EDT 2004


Hello,

The HTTP header needs two newlines: one is provided by the "print" 
statement but the other one shall be given by the string. Without the 
second newline, the server returns an error 500 "Internal Error".

Karl

matthiasjanes wrote:
> 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