[Tutor] Re: Hit Counter

Jon Cosby jcosby@mindspring.com
Thu, 2 Aug 2001 08:48:07 -0700

Thanks for the responses so far. I've made some changes, but
so far haven't resolved the problem. I've added the line

<!--#exec cgi="cgi-bin/counter.pyw"-->

to my Web page, which by the looks of it, should execute the
script each time I load the Web page. It's only running when
I the script page. Can anybody see why this is?

#! c:\python21\pythonw.exe

print "Content-type: text/html"
print "<HEAD><TITLE>Python Hit Counter</TITLE></HEAD>"
print "<BODY>"

InFile = open("count.dat", "r")
Hits = InFile.readline()
x = int(Hits) + 1
h = str(x)
OutFile = open("count.dat", "w")

print "<P><H2>Jon Cosby's web page - Total hits:</H2><br><br> "
for i in h:
	print "<img src='images/" + i + "silver.gif'>"
print "</BODY>"

Jon Cosby