fix: use http_proxy while getting image on network

This commit is contained in:
Suraj Jha 2025-08-19 15:19:57 +05:45
parent 6f483953e7
commit 4f4783bc35
No known key found for this signature in database
GPG key ID: 5AC6C16355CE2C14
2 changed files with 4 additions and 4 deletions

View file

@ -111,7 +111,7 @@ class ImageGenerationService:
return image_path
async def get_image_from_pexels(self, prompt: str) -> str:
async with aiohttp.ClientSession() as session:
async with aiohttp.ClientSession(trust_env=True) as session:
response = await session.get(
f"https://api.pexels.com/v1/search?query={prompt}&per_page=1",
headers={"Authorization": f"{get_pexels_api_key_env()}"},
@ -121,7 +121,7 @@ class ImageGenerationService:
return image_url
async def get_image_from_pixabay(self, prompt: str) -> str:
async with aiohttp.ClientSession() as session:
async with aiohttp.ClientSession(trust_env=True) as session:
response = await session.get(
f"https://pixabay.com/api/?key={get_pixabay_api_key_env()}&q={prompt}&image_type=photo&per_page=3"
)

View file

@ -19,7 +19,7 @@ async def download_file(
filename = os.path.basename(parsed_url.path)
if not filename or "." not in filename:
async with aiohttp.ClientSession() as session:
async with aiohttp.ClientSession(trust_env=True) as session:
async with session.head(url, headers=headers) as response:
if response.status == 200:
content_disposition = response.headers.get(
@ -41,7 +41,7 @@ async def download_file(
filename = filename or get_random_uuid()
save_path = os.path.join(save_directory, filename)
async with aiohttp.ClientSession() as session:
async with aiohttp.ClientSession(trust_env=True) as session:
async with session.get(url, headers=headers) as response:
if response.status == 200:
with open(save_path, "wb") as file: