Skip to content

Commit 07dcc62

Browse files
committed
Fix
1 parent 8b95e43 commit 07dcc62

4 files changed

Lines changed: 10 additions & 7 deletions

File tree

app/api/routes.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,12 @@ async def home(session: Session = Depends(get_session)):
5353
stats = metrics.snapshot()
5454
totals = fetch_storage_totals(session)
5555
uploads_count = max(int(stats.get("uploads", 0)), totals["total_files"])
56+
max_file_text = f"{MAX_FILE_SIZE_MB:.1f} MB"
5657

5758
html = render_template(
5859
"pages/home.html",
5960
{
60-
"max_file_mb": f"{MAX_FILE_SIZE_MB:.1f}",
61+
"max_file_text": max_file_text,
6162
"uploads": str(uploads_count),
6263
"downloads": str(stats.get("downloads", 0)),
6364
"deleted": str(stats.get("deleted", 0)),
@@ -70,9 +71,10 @@ async def home(session: Session = Depends(get_session)):
7071

7172
@router.get("/api-info", response_class=HTMLResponse)
7273
async def api_info():
74+
max_file_text = f"{MAX_FILE_SIZE_MB:.1f} MB"
7375
html = render_template(
7476
"pages/api.html",
75-
{"max_file_mb": f"{MAX_FILE_SIZE_MB:.1f}", "rate_limit": str(RATE_LIMIT_PER_MINUTE)},
77+
{"max_file_text": max_file_text, "rate_limit": str(RATE_LIMIT_PER_MINUTE)},
7678
)
7779
return HTMLResponse(content=html)
7880

@@ -185,7 +187,7 @@ async def _auth_admin(request: Request, allow_blank: bool):
185187
duration = state["penalty"] * ADMIN_LOCK_STEP_SECONDS
186188
state["lock_until"] = now + timedelta(seconds=duration)
187189
minutes = max(1, duration // 60)
188-
msg = f"Too many failures. Locked for {minutes} minutes."
190+
msg = f"Too many attempts. Too many failures. Locked for {minutes} minutes."
189191
if allow_blank:
190192
return False, msg, True
191193
raise HTTPException(status_code=429, detail=msg)

app/templates/pages/api.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
<h1>AlterBase CDN API</h1>
1212
<p class="lead">
1313
Upload files and retrieve shareable URLs with a minimal HTTP API. Each client is limited to
14-
${rate_limit} requests per minute and individual uploads are capped at ${max_file_mb} MB.
14+
${rate_limit} requests per minute and individual uploads are capped at ${max_file_text}.
1515
</p>
16+
<p class="meta">Maximum upload size per file: <strong>${max_file_text}</strong></p>
1617

1718
<section>
1819
<h2>Base URL</h2>
@@ -24,7 +25,7 @@ <h2>Endpoints</h2>
2425
<ul>
2526
<li>
2627
<strong>POST /upload</strong><br />
27-
Multipart form request with <code>file</code> field (max ${max_file_mb} MB). Returns JSON metadata with
28+
Multipart form request with <code>file</code> field (max ${max_file_text}). Returns JSON metadata with
2829
<code>id</code>, <code>url</code>, <code>size</code>, <code>type</code>.
2930
</li>
3031
<li>

app/templates/pages/home.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<main>
1111
<h1>AlterBase CDN</h1>
1212
<p>
13-
Fast minimal API for hosting images and assets. Upload files (up to ${max_file_mb} MB), retrieve shareable
13+
Fast minimal API for hosting images and assets. Upload files (up to ${max_file_text}), retrieve shareable
1414
URLs, and keep storage tidy with automatic cleanup.
1515
</p>
1616
<div class="metrics-grid">

tests/test_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from fastapi.testclient import TestClient
88

99

10-
def _prepare_client(tmp_path, monkeypatch, *, rate_limit="5", max_size="1024", cache_age="120", lock_step="60"):
10+
def _prepare_client(tmp_path, monkeypatch, *, rate_limit="5", max_size=str(10 * 1024 * 1024), cache_age="120", lock_step="60"):
1111
project_root = Path(__file__).resolve().parents[1]
1212
project_root_str = str(project_root)
1313
if project_root_str not in sys.path:

0 commit comments

Comments
 (0)