This page counter was a CGI experiment in what it would take to implement such a simple concept. This is committed for archival to be run under Python 2.5 or later versions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | import cPickle
import Zcgi
def main():
try:
count = cPickle.load(file('count.txt'))
except:
count = 0
count += 1
cPickle.dump(count, file('count.txt', 'w'))
Zcgi.print_plain(str(count))
if __name__ == '__main__':
Zcgi.execute(main, 'cgi')
|
The Zcgi
module can be found in recipe 475112.