feat: end-point for deal document generation
This commit is contained in:
20
utils/images_fetcher.py
Normal file
20
utils/images_fetcher.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import asyncio
|
||||
import base64
|
||||
from typing import List, Tuple
|
||||
|
||||
import aiohttp
|
||||
|
||||
|
||||
async def fetch_image(url: str) -> str:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(url) as response:
|
||||
if response.status == 200:
|
||||
image_data = await response.read()
|
||||
return base64.b64encode(image_data).decode("utf-8")
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
||||
async def fetch_images(urls: List[str]) -> Tuple[str]:
|
||||
tasks = [fetch_image(url) for url in urls]
|
||||
return await asyncio.gather(*tasks)
|
||||
Reference in New Issue
Block a user