Forcing Python to detect DocumentRoot

Michael Torrie torriem at gmail.com
Mon Jan 21 13:42:06 EST 2013


On 01/21/2013 07:55 AM, Ferrous Cranus wrote:
> Yes Dave so we need to remove <img src="/data/images/mail.png">
> since the apache cant see to open it and let Python open it which we
> know it can because it has access to any system file the user has
> access too.

What are you trying to accomplish?  I don't see how opening the file
with python will do anything because as has been said many times on this
thread, your python CGI generates html code which the browser then
renders.  Opening an image file with python will do nothing useful.

> So if a python script can open any file the user has access too then
> we need a "python way" of opening this file.

Still don't understand why you want python to open the image file.  What
do you want python to do with it?  It's running on a web server, so
there's no screen for python to display the image too.

Technically it is possible to have a script that opens the image and
serves it up as a binary stream to the browser using the image
content-type header, but it's way more efficient to serve up the file
statically.  And you'd have to have a proper link in the html code
anyway, to refer to your image-serving CGI script.

Methinks you're barking up the wrong tree with python opening the image
file.




More information about the Python-list mailing list