$P@D$3RV£R commited on
Commit
09628c7
·
1 Parent(s): d99088b

Add cumulative analytics tracking with persistent statistics (visits, unique visitors, countries, dates)

Browse files
Files changed (3) hide show
  1. app.py +12 -2
  2. requirements.txt +1 -0
  3. templates/tagger.html +5 -0
app.py CHANGED
@@ -5,13 +5,18 @@ import argparse
5
  from flask import Flask, redirect, url_for, request
6
  from flask import render_template
7
  from flask import send_file
8
- import os
9
  from datasets import load_dataset
10
  from huggingface_hub import hf_hub_download
11
  from io import BytesIO
12
  from PIL import Image
13
  import tempfile
14
- import shutil
 
 
 
 
 
15
 
16
  app = Flask(__name__)
17
  app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
@@ -19,10 +24,15 @@ app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
19
  @app.route('/')
20
  def index():
21
  """Redirect root URL to tagger"""
 
 
22
  return redirect(url_for('tagger'))
23
 
24
  @app.route('/tagger')
25
  def tagger():
 
 
 
26
  # Check if dataset was loaded successfully
27
  folder_sets = app.config.get("FOLDER_SETS", [])
28
  if not folder_sets:
 
5
  from flask import Flask, redirect, url_for, request
6
  from flask import render_template
7
  from flask import send_file
8
+ import os
9
  from datasets import load_dataset
10
  from huggingface_hub import hf_hub_download
11
  from io import BytesIO
12
  from PIL import Image
13
  import tempfile
14
+ import shutil
15
+ import json
16
+ from datetime import datetime
17
+ import hashlib
18
+ import threading
19
+ import requests
20
 
21
  app = Flask(__name__)
22
  app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
 
24
  @app.route('/')
25
  def index():
26
  """Redirect root URL to tagger"""
27
+ # Track visit
28
+ track_visit()
29
  return redirect(url_for('tagger'))
30
 
31
  @app.route('/tagger')
32
  def tagger():
33
+ # Track visit
34
+ track_visit()
35
+
36
  # Check if dataset was loaded successfully
37
  folder_sets = app.config.get("FOLDER_SETS", [])
38
  if not folder_sets:
requirements.txt CHANGED
@@ -2,4 +2,5 @@ flask
2
  datasets
3
  huggingface_hub
4
  Pillow
 
5
 
 
2
  datasets
3
  huggingface_hub
4
  Pillow
5
+ requests
6
 
templates/tagger.html CHANGED
@@ -129,6 +129,11 @@
129
  <div class="row">
130
  <text>Folder {{ head }} / {{ len }}: {{ current_folder }} | Image Set {{ image_set_index }} / {{ max_sets }}</text>
131
  <div style="float:right;">
 
 
 
 
 
132
  <!-- Folder Navigation - Always available in continuous loop mode -->
133
  <a href="/prev_folder" style="background: transparent; color: #dc3545; border: 2px solid #dc3545; padding: 8px 12px; border-radius: 5px; text-decoration: none; font-size: 14px; margin-right: 8px; font-weight: bold;" title="Previous folder (loops to end)">
134
  <span class="glyphicon glyphicon-chevron-left"></span><span class="glyphicon glyphicon-chevron-left"></span> Prev Folder
 
129
  <div class="row">
130
  <text>Folder {{ head }} / {{ len }}: {{ current_folder }} | Image Set {{ image_set_index }} / {{ max_sets }}</text>
131
  <div style="float:right;">
132
+ <!-- Statistics Link -->
133
+ <a href="/stats" style="background: transparent; color: #6c757d; border: 2px solid #6c757d; padding: 8px 12px; border-radius: 5px; text-decoration: none; font-size: 14px; margin-right: 8px; font-weight: bold;" title="View Analytics Statistics">
134
+ 📊 Stats
135
+ </a>
136
+
137
  <!-- Folder Navigation - Always available in continuous loop mode -->
138
  <a href="/prev_folder" style="background: transparent; color: #dc3545; border: 2px solid #dc3545; padding: 8px 12px; border-radius: 5px; text-decoration: none; font-size: 14px; margin-right: 8px; font-weight: bold;" title="Previous folder (loops to end)">
139
  <span class="glyphicon glyphicon-chevron-left"></span><span class="glyphicon glyphicon-chevron-left"></span> Prev Folder