Download app.py from 05prey/dummy_end: direct link, hf CLI and curl.
- Browser
- Download file 925 Bytes
-
https://huggingface.co/spaces/05prey/dummy_end/resolve/main/app.py
- Command line
-
hf download hf://spaces/05prey/dummy_end/app.py
-
curl -L -o app.py https://huggingface.co/spaces/05prey/dummy_end/resolve/main/app.py
925 Bytes
| import time | |
| from fastapi import FastAPI, UploadFile, File | |
| from fastapi.responses import HTMLResponse | |
| api = FastAPI() | |
| def home(): | |
| return """ | |
| <h2>Dummy Upload Sink</h2> | |
| <p>POST a file to <code>/upload</code>.</p> | |
| <pre> | |
| curl -X POST https://YOUR_SPACE_URL/upload -F "file=@study.zip" | |
| </pre> | |
| """ | |
| async def upload_sink(file: UploadFile = File(...)): | |
| start = time.time() | |
| total = 0 | |
| while True: | |
| chunk = await file.read(1024 * 1024) # 1MB chunks | |
| if not chunk: | |
| break | |
| total += len(chunk) | |
| dt = time.time() - start | |
| mb = total / (1024**2) | |
| return { | |
| "filename": file.filename, | |
| "received_mb": round(mb, 2), | |
| "duration_sec": round(dt, 2), | |
| "throughput_mb_s": round(mb / dt, 2) if dt > 0 else 0.0, | |
| } | |
| # IMPORTANT: export this variable named `app` | |
| app = api | |