Code:
# =================================================================================================================
# return general counter, render the page and print it
# =================================================================================================================
cur.execute( '''SELECT hits FROM counters WHERE URL = %s''', (htmlpage,) )
data = cur.fetchone()

if cur.rowcount:
	# open html template
	if htmlpage.endswith('.html'):
		f = open( "/home/nikos/public_html/" + htmlpage )
	else:
		f = open( "/home/nikos/public_html/cgi-bin/" + htmlpage )
		
	
	# render html template and save
	htmldata = f.read()
	counter = '''<center><a href="mailto:support@superhost.gr"> <img src="/data/images/mail.png"> </a>
		     <center><table border=2 cellpadding=2 bgcolor=black>
		     		<td><font color=lime>Αριθμός Επισκεπτών</td>
				<td><a href="http://superhost.gr?show=stats"><font color=cyan> %d </td>''' % data[0]
				
	
	template = htmldata + counter
	print ( template )
I'am trying to emven a counter after each .html or .py file thet the user requests, so to keep track how many times the file has been accessed.
The html files appear and work ok, but the .py files appear as documents instead of runnign as cgi scripts.

Can you help please?