Compare commits

...

2 Commits

2 changed files with 93 additions and 21 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

@@ -6,9 +6,53 @@
<title>临时文件传输</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { margin: 0; padding: 0; }
.container { width: auto; height: auto; overflow: visible; }
h1 { font-size: 16px; color: #333; height: auto; overflow: visible; }
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; }
@@ -25,8 +69,30 @@
</style>
</head>
<body>
<div class="container">
<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">
<div class="upload-area" id="uploadArea">
<input type="file" id="fileInput">
<p>点击或拖拽文件到此处</p>