En Sun, 12 Oct 2008 06:48:29 -0300, rodmc <[EMAIL PROTECTED]> escribió:

I am trying to figure out how to create a Python script which will
open a file from a folder outwith the public_html path and serve it
directly to the user for downloading. The aim being so that the users
cannot see where the file is served from. Is there an easy way to do
this, or an HTML header I am missing or an easy way in Python?

Just emit the right Content-Type, maybe Content-Length, and the file contents itself.

#!/usr/bin/python

f = open("/path/to/file.jpg", "rb")
data = f.read()
f.close()

print "Content-Type: image/jpeg"
print "Content-Length: %d" % len(data)
print
print data

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to