CGI script to count downloads
Kragen Sitaker
kragen at dnaco.net
Tue Apr 3 03:11:14 EDT 2001
In article <3AC95ECE.B8F5E93E at cosc.canterbury.ac.nz>,
Greg Ewing <greg at cosc.canterbury.ac.nz> wrote:
>So, my question is, can I put anything in the
>headers of the response to give the browser a
>hint as to what name the file should be saved
>under?
>
>Or is there a better way of going about this
>whole counting business?
Perhaps you could make the URL end with download.py/foo/bar/baz.tar.gz
instead of using a query; then just use PATH_INFO instead of a form
value. Is that possible?
> #!/usr/local/cosc/bin/python
> print "Content-Type: compressed/gzip"
I don't think that's correct ;)
> form = cgi.FieldStorage()
> path = form["file"].value
> f = open(path)
Yow. file=/etc/passwd, anyone? At least this isn't Perl, where
file=|sh would work :)
Doesn't appear you're actually counting yet. Be sure to flock when
you do :)
--
<kragen at pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Perilous to all of us are the devices of an art deeper than we possess
ourselves.
-- Gandalf the White [J.R.R. Tolkien, "The Two Towers", Bk 3, Ch. XI]
More information about the Python-list
mailing list