Merge pull request #232 from presenton/fix/image_generation_proxy
fix: use http_proxy while getting image on network
This commit is contained in:
commit
c1d2985e48
2 changed files with 4 additions and 4 deletions
|
|
@ -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"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue