Update app.py
Browse files
app.py
CHANGED
|
@@ -8,10 +8,7 @@ app = FastAPI()
|
|
| 8 |
def home():
|
| 9 |
return """
|
| 10 |
<h2>Dummy Upload Sink</h2>
|
| 11 |
-
<p>POST
|
| 12 |
-
<pre>
|
| 13 |
-
curl -X POST https://YOUR_SPACE_URL/upload -F "file=@study.zip"
|
| 14 |
-
</pre>
|
| 15 |
"""
|
| 16 |
|
| 17 |
@app.post("/upload")
|
|
@@ -19,7 +16,7 @@ async def upload_sink(file: UploadFile = File(...)):
|
|
| 19 |
start = time.time()
|
| 20 |
total = 0
|
| 21 |
while True:
|
| 22 |
-
chunk = await file.read(1024 * 1024)
|
| 23 |
if not chunk:
|
| 24 |
break
|
| 25 |
total += len(chunk)
|
|
@@ -32,3 +29,6 @@ async def upload_sink(file: UploadFile = File(...)):
|
|
| 32 |
"duration_sec": round(dt, 2),
|
| 33 |
"throughput_mb_s": round(mb / dt, 2) if dt > 0 else 0.0,
|
| 34 |
}
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
def home():
|
| 9 |
return """
|
| 10 |
<h2>Dummy Upload Sink</h2>
|
| 11 |
+
<p>POST to <code>/upload</code></p>
|
|
|
|
|
|
|
|
|
|
| 12 |
"""
|
| 13 |
|
| 14 |
@app.post("/upload")
|
|
|
|
| 16 |
start = time.time()
|
| 17 |
total = 0
|
| 18 |
while True:
|
| 19 |
+
chunk = await file.read(1024 * 1024)
|
| 20 |
if not chunk:
|
| 21 |
break
|
| 22 |
total += len(chunk)
|
|
|
|
| 29 |
"duration_sec": round(dt, 2),
|
| 30 |
"throughput_mb_s": round(mb / dt, 2) if dt > 0 else 0.0,
|
| 31 |
}
|
| 32 |
+
|
| 33 |
+
# Optional: print PORT for debugging in container logs
|
| 34 |
+
print("DEBUG PORT env:", os.environ.get("PORT"), flush=True)
|