feat(ui): beautiful status page with file size and expiry info, 1px form hidden
This commit is contained in:
8
app.py
8
app.py
@@ -3,6 +3,9 @@ import uuid
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from flask import Flask, request, render_template, send_file, jsonify, url_for, abort
|
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
|
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
|
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__)
|
app = Flask(__name__)
|
||||||
@@ -15,7 +18,10 @@ init_db()
|
|||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
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'])
|
@app.route('/upload', methods=['POST'])
|
||||||
def upload():
|
def upload():
|
||||||
|
|||||||
@@ -7,82 +7,52 @@
|
|||||||
<style>
|
<style>
|
||||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||||
body {
|
body {
|
||||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
margin: 0; padding: 0;
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
|
display: flex; justify-content: center; align-items: center;
|
||||||
}
|
}
|
||||||
.container {
|
.status-card {
|
||||||
background: rgba(255,255,255,0.95);
|
background: white;
|
||||||
padding: 40px 50px;
|
border-radius: 16px;
|
||||||
border-radius: 12px;
|
padding: 48px 56px;
|
||||||
box-shadow: 0 20px 60px rgba(0,0,0,0.15);
|
box-shadow: 0 20px 60px rgba(0,0,0,0.15);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
max-width: 480px;
|
max-width: 480px;
|
||||||
}
|
}
|
||||||
.status-dot {
|
.status-icon {
|
||||||
width: 12px;
|
font-size: 56px;
|
||||||
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;
|
margin-bottom: 16px;
|
||||||
}
|
}
|
||||||
.info-card {
|
h1 {
|
||||||
flex: 1;
|
|
||||||
background: #f1f5f9;
|
|
||||||
padding: 16px 12px;
|
|
||||||
border-radius: 8px;
|
|
||||||
}
|
|
||||||
.info-card .icon {
|
|
||||||
font-size: 28px;
|
font-size: 28px;
|
||||||
margin-bottom: 6px;
|
font-weight: 700;
|
||||||
|
color: #1a1a2e;
|
||||||
|
margin-bottom: 8px;
|
||||||
}
|
}
|
||||||
.info-card .label {
|
.status-tag {
|
||||||
font-size: 12px;
|
display: inline-block;
|
||||||
color: #64748b;
|
background: #d4edda;
|
||||||
text-transform: uppercase;
|
color: #155724;
|
||||||
letter-spacing: 0.5px;
|
padding: 4px 14px;
|
||||||
}
|
border-radius: 12px;
|
||||||
.info-card .value {
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #334155;
|
|
||||||
}
|
|
||||||
.api-hint {
|
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
color: #94a3b8;
|
font-weight: 600;
|
||||||
margin-top: 8px;
|
margin-bottom: 24px;
|
||||||
line-height: 1.6;
|
|
||||||
}
|
}
|
||||||
.api-hint code {
|
.info-row {
|
||||||
background: #e2e8f0;
|
display: flex;
|
||||||
padding: 2px 6px;
|
justify-content: space-between;
|
||||||
border-radius: 3px;
|
padding: 12px 0;
|
||||||
font-size: 12px;
|
border-bottom: 1px solid #eef0f5;
|
||||||
color: #475569;
|
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 { 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:hover, .upload-area.dragover { border-color: transparent; background: transparent; }
|
||||||
.upload-area input { display: none; }
|
.upload-area input { display: none; }
|
||||||
@@ -99,32 +69,30 @@
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<div class="status-card">
|
||||||
|
<div class="status-icon">⚡</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">
|
<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">
|
<div class="upload-area" id="uploadArea">
|
||||||
<input type="file" id="fileInput">
|
<input type="file" id="fileInput">
|
||||||
<p>点击或拖拽文件到此处</p>
|
<p>点击或拖拽文件到此处</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user