nomad*** at ***freemail.absa.co.za
Tue Oct 16 15:28:33 CEST 2001
On Fri, 12 Oct 2001 12:59:04 -0700 (PDT), Neal Irwin
<sap2002us at yahoo.com> 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
# Begin counter code :::
## $Id: default.py,v 1.1 2001-05-24 18:11:06+02 Nomad Exp $
print "Content-Type: text/html\n\n"
fileRead = open('count.txt', 'r')
intHits = string.strip(fileRead.read())
# print "<p>intHits = " + intHits + "</p>"
if intHits == '':
intHits = 0
intHits = string.atoi(intHits) + 1
fileWrite = open('count.txt', 'w')
# followed by a long print """...""" containing
# the html template that uses the counter data.
# End counter code :::
Pretty simple, but it works...
Wondering of the vast emptyness of the 'net
in search of something cool.
More information about the Python-list