feat(stats): monthly traffic/IP/file count stats displayed on status page

This commit is contained in:
OpenCode Bot
2026-05-11 22:11:11 +08:00
parent 9c7f8f0f62
commit 4561aec7e0
3 changed files with 64 additions and 2 deletions

6
app.py
View File

@@ -6,7 +6,7 @@ from config import UPLOAD_FOLDER, SECRET_KEY, MAX_CONTENT_LENGTH, EXPIRY_OPTIONS
MAX_FILE_SIZE_MB = MAX_CONTENT_LENGTH // (1024 * 1024)
DAILY_GB = DAILY_TRAFFIC_LIMIT // (1024 * 1024 * 1024)
from database import init_db, add_file, get_file, delete_file, cleanup_expired, add_upload_traffic, add_download_traffic, get_client_ip, is_traffic_exceeded, get_daily_traffic
from database import init_db, add_file, get_file, delete_file, cleanup_expired, add_upload_traffic, add_download_traffic, get_client_ip, is_traffic_exceeded, get_daily_traffic, get_monthly_stats
app = Flask(__name__)
app.config['SECRET_KEY'] = SECRET_KEY
@@ -18,10 +18,12 @@ init_db()
@app.route('/')
def index():
stats = get_monthly_stats()
return render_template('index.html',
expiry_options=EXPIRY_OPTIONS,
max_file_size_mb=MAX_FILE_SIZE_MB,
daily_gb=DAILY_GB)
daily_gb=DAILY_GB,
stats=stats)
@app.route('/upload', methods=['POST'])
def upload():