Process multiple images with progress streaming.
(data: ImageBatchRequest)
| 233 | |
| 234 | @app.post("/api/image/process-batch") |
| 235 | async def process_image_batch(data: ImageBatchRequest): |
| 236 | """ |
| 237 | Process multiple images with progress streaming. |
| 238 | """ |
| 239 | async def generate(): |
| 240 | try: |
| 241 | client = await get_dirty_client_async() |
| 242 | async for progress in client.stream_async( |
| 243 | IMAGE_WORKER, |
| 244 | "process_batch", |
| 245 | images=data.images, |
| 246 | operation=data.operation, |
| 247 | width=data.width, |
| 248 | height=data.height, |
| 249 | size=data.size, |
| 250 | ): |
| 251 | yield f"data: {json.dumps(progress)}\n\n" |
| 252 | except DirtyError as e: |
| 253 | yield f"data: {json.dumps({'error': str(e)})}\n\n" |
| 254 | |
| 255 | return StreamingResponse( |
| 256 | generate(), |
| 257 | media_type="text/event-stream", |
| 258 | ) |
| 259 | |
| 260 | |
| 261 | @app.get("/api/image/stats") |
nothing calls this directly
no test coverage detected