rikard at strakt.com
Mon Oct 15 08:00:53 CEST 2001
Neal Irwin wrote:
> Does anyone have sample code for a web-page hit
> counter. I was curious what one would look like in
> Python. I have made one in Perl and would like to
> compare them.
You can use some ugly hack like this:
FILE = "/tmp/counter"
if not os.path.exists(FILE):
c = 0
c = int(open(FILE).readline())
# increase the counter
c = c + 1
>>> ## working on region in file /tmp/python-3601Dum...
>>> ## working on region in file /tmp/python-3601Q4s...
>>> ## working on region in file /tmp/python-3601dCz...
More information about the Python-list