“`python
#!\/usr\/bin\/env python
import cgi
import cgitb
import os.path

# カウンターファイルのパス
counter_file = “counter.txt”

# カウントを更新する関数
def update_counter():
# カウンターファイルが存在するか確認
if os.path.exists(counter_file):
# カウンターファイルが存在する場合、現在の値を読み込む
with open(counter_file, “r”) as f:
count = int(f.read())
else:
# カウンターファイルが存在しない場合、カウントを0に設定
count = 0

# カウントをインクリメント
count += 1

# カウンターファイルを更新
with open(counter_file, “w”) as f:
f.write(str(count))

return count

# エラーハンドリング設定
cgitb.enable()

# フォームデータの取得
form = cgi.FieldStorage()

# カウントの種類に応じてカウンターを更新
if “type” in form:
count_type = form[“type”].value

if count_type == “total”:
count = update_counter()
elif count_type == “today”:
# 本日カウントの場合、ファイルの更新日時からカウントを取得
count = os.path.getmtime(counter_file)
elif count_type == “yesterday”:
# 昨日カウントの場合、ファイルの更新日時からカウントを取得
count = os.path.getmtime(counter_file) – 86400 # 1日の秒数

# レスポンスの出力
print(“Content-Type: text\/html”)
print()
print(“”)print(“”)
print(“