Saving a hit counter in a file is the worst solution. There will be concurrency problems without very good solutions.
The correct approach is to store the hits in a database.
Create the hit_log table:
The hit adder:
create table hit_log (hit_time timestamp default current_timestamp);
To query the hit_log table:
import psycopg2 as db
connection = db.connect('host=localhost dbname=test user=user password=password')
cursor = connection.cursor()
query = 'insert into hit_log default values'
The samples use the postgresql database. Translate it to your database.
select count(*) from hit_log where hit_time::date = '2006-12-11'::date;