feat(ui): beautiful status page with file size and expiry info, 1px form hidden

This commit is contained in:
OpenCode Bot
2026-05-11 21:37:36 +08:00
parent a9c2b69112
commit 9c7f8f0f62
2 changed files with 94 additions and 120 deletions

8
app.py
View File

@@ -3,6 +3,9 @@ import uuid
from datetime import datetime
from flask import Flask, request, render_template, send_file, jsonify, url_for, abort
from config import UPLOAD_FOLDER, SECRET_KEY, MAX_CONTENT_LENGTH, EXPIRY_OPTIONS, DAILY_TRAFFIC_LIMIT
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
app = Flask(__name__)
@@ -15,7 +18,10 @@ init_db()
@app.route('/')
def index():
return render_template('index.html', expiry_options=EXPIRY_OPTIONS)
return render_template('index.html',
expiry_options=EXPIRY_OPTIONS,
max_file_size_mb=MAX_FILE_SIZE_MB,
daily_gb=DAILY_GB)
@app.route('/upload', methods=['POST'])
def upload():

View File

@@ -4,127 +4,95 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>临时文件传输</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.container {
background: rgba(255,255,255,0.95);
padding: 40px 50px;
border-radius: 12px;
box-shadow: 0 20px 60px rgba(0,0,0,0.15);
text-align: center;
max-width: 480px;
}
.status-dot {
width: 12px;
height: 12px;
background: #4ade80;
border-radius: 50%;
display: inline-block;
margin-right: 8px;
animation: pulse 2s infinite;
}
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.4; }
}
h1 {
font-size: 24px;
color: #1e293b;
margin-bottom: 20px;
display: flex;
align-items: center;
justify-content: center;
}
.info-cards {
display: flex;
gap: 12px;
margin-bottom: 16px;
}
.info-card {
flex: 1;
background: #f1f5f9;
padding: 16px 12px;
border-radius: 8px;
}
.info-card .icon {
font-size: 28px;
margin-bottom: 6px;
}
.info-card .label {
font-size: 12px;
color: #64748b;
text-transform: uppercase;
letter-spacing: 0.5px;
}
.info-card .value {
font-size: 16px;
font-weight: 600;
color: #334155;
}
.api-hint {
font-size: 13px;
color: #94a3b8;
margin-top: 8px;
line-height: 1.6;
}
.api-hint code {
background: #e2e8f0;
padding: 2px 6px;
border-radius: 3px;
font-size: 12px;
color: #475569;
}
.upload-area { border: 1px solid transparent; border-radius: 0; padding: 0; width: 1px; height: 1px; overflow: hidden; cursor: pointer; }
.upload-area:hover, .upload-area.dragover { border-color: transparent; background: transparent; }
.upload-area input { display: none; }
.upload-area p { font-size: 1px; color: transparent; }
.expiry { width: 1px; height: 1px; overflow: hidden; }
.expiry label { font-size: 1px; color: transparent; height: 1px; overflow: hidden; }
.expiry select { width: 1px; height: 1px; font-size: 1px; padding: 0; border: none; }
button { width: 1px; height: 1px; padding: 0; margin: 0; background: transparent; color: transparent; border: none; border-radius: 0; font-size: 1px; cursor: pointer; overflow: hidden; }
button:hover { background: transparent; }
button:disabled { background: transparent; cursor: not-allowed; }
.result { width: 1px; height: 1px; overflow: hidden; }
.result a { font-size: 1px; color: transparent; }
.error { width: 1px; height: 1px; overflow: hidden; font-size: 1px; color: transparent; }
</style>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
margin: 0; padding: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex; justify-content: center; align-items: center;
}
.status-card {
background: white;
border-radius: 16px;
padding: 48px 56px;
box-shadow: 0 20px 60px rgba(0,0,0,0.15);
text-align: center;
max-width: 480px;
}
.status-icon {
font-size: 56px;
margin-bottom: 16px;
}
h1 {
font-size: 28px;
font-weight: 700;
color: #1a1a2e;
margin-bottom: 8px;
}
.status-tag {
display: inline-block;
background: #d4edda;
color: #155724;
padding: 4px 14px;
border-radius: 12px;
font-size: 13px;
font-weight: 600;
margin-bottom: 24px;
}
.info-row {
display: flex;
justify-content: space-between;
padding: 12px 0;
border-bottom: 1px solid #eef0f5;
font-size: 15px;
color: #555;
}
.info-row:last-child { border-bottom: none; }
.info-label { font-weight: 500; color: #888; }
.info-value { font-weight: 600; color: #1a1a2e; }
.container { width: 1px; height: 1px; overflow: hidden; }
.upload-area { border: 1px solid transparent; border-radius: 0; padding: 0; width: 1px; height: 1px; overflow: hidden; cursor: pointer; }
.upload-area:hover, .upload-area.dragover { border-color: transparent; background: transparent; }
.upload-area input { display: none; }
.upload-area p { font-size: 1px; color: transparent; }
.expiry { width: 1px; height: 1px; overflow: hidden; }
.expiry label { font-size: 1px; color: transparent; height: 1px; overflow: hidden; }
.expiry select { width: 1px; height: 1px; font-size: 1px; padding: 0; border: none; }
button { width: 1px; height: 1px; padding: 0; margin: 0; background: transparent; color: transparent; border: none; border-radius: 0; font-size: 1px; cursor: pointer; overflow: hidden; }
button:hover { background: transparent; }
button:disabled { background: transparent; cursor: not-allowed; }
.result { width: 1px; height: 1px; overflow: hidden; }
.result a { font-size: 1px; color: transparent; }
.error { width: 1px; height: 1px; overflow: hidden; font-size: 1px; color: transparent; }
</style>
</head>
<body>
<div class="status-card">
<div class="status-icon">&#9889;</div>
<h1>服务正在运行中</h1>
<span class="status-tag">运行正常</span>
<div class="info-row">
<span class="info-label">最大文件大小</span>
<span class="info-value">{{ max_file_size_mb }} MB</span>
</div>
<div class="info-row">
<span class="info-label">可保存时间</span>
<span class="info-value">1小时 / 24小时 / 7天</span>
</div>
<div class="info-row">
<span class="info-label">每日流量限制</span>
<span class="info-value">{{ daily_gb }} GB / IP</span>
</div>
<div class="info-row">
<span class="info-label">API 上传</span>
<span class="info-value">POST /api/upload</span>
</div>
</div>
<div class="container">
<h1><span class="status-dot"></span>服务正在运行中</h1>
<div class="info-cards">
<div class="info-card">
<div class="icon">📦</div>
<div class="label">最大文件大小</div>
<div class="value">500 MB</div>
</div>
<div class="info-card">
<div class="icon"></div>
<div class="label">最长保存时间</div>
<div class="value">7 天</div>
</div>
<div class="info-card">
<div class="icon">📊</div>
<div class="label">每日流量限制</div>
<div class="value">20 GB / IP</div>
</div>
</div>
<div class="api-hint">
上传方式API 调用 <code>POST /api/upload</code> 或使用 <code>upload_client.py</code><br>
过期选项:<code>1h</code> / <code>24h</code> / <code>7d</code>
</div>
<div class="upload-area" id="uploadArea">
<input type="file" id="fileInput">
<p>点击或拖拽文件到此处</p>
@@ -219,4 +187,4 @@
}
</script>
</body>
</html>
</html>