Update app.py
Browse files
app.py
CHANGED
|
@@ -174,8 +174,8 @@ async def generate(
|
|
| 174 |
|
| 175 |
|
| 176 |
@app.get("/image/{image_id}")
|
| 177 |
-
def get_image(image_id: str, download: Optional[bool] = False
|
| 178 |
-
"""Retrieve stored image by ID (
|
| 179 |
try:
|
| 180 |
oid = ObjectId(image_id)
|
| 181 |
grid_out = fs.get(oid)
|
|
@@ -189,7 +189,12 @@ def get_image(image_id: str, download: Optional[bool] = False, user=Depends(veri
|
|
| 189 |
if download:
|
| 190 |
headers["Content-Disposition"] = f'attachment; filename="{grid_out.filename}"'
|
| 191 |
|
| 192 |
-
return StreamingResponse(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
|
| 194 |
# ---------------------------------------------------------------------
|
| 195 |
# Run locally
|
|
|
|
| 174 |
|
| 175 |
|
| 176 |
@app.get("/image/{image_id}")
|
| 177 |
+
def get_image(image_id: str, download: Optional[bool] = False):
|
| 178 |
+
"""Retrieve stored image by ID (no authentication required)."""
|
| 179 |
try:
|
| 180 |
oid = ObjectId(image_id)
|
| 181 |
grid_out = fs.get(oid)
|
|
|
|
| 189 |
if download:
|
| 190 |
headers["Content-Disposition"] = f'attachment; filename="{grid_out.filename}"'
|
| 191 |
|
| 192 |
+
return StreamingResponse(
|
| 193 |
+
iterfile(),
|
| 194 |
+
media_type=grid_out.content_type or "application/octet-stream",
|
| 195 |
+
headers=headers
|
| 196 |
+
)
|
| 197 |
+
|
| 198 |
|
| 199 |
# ---------------------------------------------------------------------
|
| 200 |
# Run locally
|