CGI script to count downloads

Walter Hofmann spamdropbox at myrealbox.com
Wed Apr 4 13:08:46 EDT 2001


On Tue, 03 Apr 2001 17:25:34 +1200, Greg Ewing <greg at cosc.canterbury.ac.nz> wrote:
>
>I'm trying to write a script that will keep a count
>of the number of times a file is downloaded. So far,
>the script just takes the name of the required file,
>opens the file, and passes on its contents.

Use the following commands to redirect the browser to the "real" URL
where the file is located:

print "Location: http://server/real/url.tar.gz"
print "Status: 302 Found"
print

This will make sure the browser gets the right name and you don't have
to pipe the whole file through the cgi script.

Walter



More information about the Python-list mailing list