this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

streaming

alice 70fc8087 51b008f0

+6 -3
+6 -3
app.py
··· 7 7 from typing import Dict 8 8 9 9 from fastapi import FastAPI, HTTPException 10 + from fastapi.responses import StreamingResponse 10 11 from pydantic import BaseModel 11 12 from concurrent.futures import ThreadPoolExecutor 12 13 import aiohttp ··· 53 54 pass 54 55 55 56 56 - def parse_car(car_file_path: str) -> str: 57 - return json.dumps(print_all_records(car_file_path, True)) 57 + async def parse_car(car_file_path: str) -> str: 58 + records = print_all_records(car_file_path, True) 59 + for k, v in records.items(): 60 + yield json.dumps({k: v}) + "\n" 58 61 59 62 60 63 @retry( ··· 154 157 logging.error(f"Error parsing CAR file: {e}") 155 158 raise HTTPException(status_code=500, detail="Error parsing CAR file.") 156 159 157 - return parsed_data 160 + return StreamingResponse(parsed_data)