AiCoderv2's picture
Deploy Gradio app with multiple files
9f9394b verified
raw
history blame contribute delete
735 Bytes
#
# SPDX-FileCopyrightText: Hadad <[email protected]>
# SPDX-License-Identifier: Apache-2.0
#
import aiohttp
from config import (
READER,
TIMEOUT,
AIOHTTP,
HEADERS,
REMINDERS
)
async def open_link(url):
try:
async with aiohttp.ClientSession(
connector=aiohttp.TCPConnector(**AIOHTTP),
timeout=aiohttp.ClientTimeout(total=TIMEOUT),
headers=HEADERS
) as session:
async with session.post(READER, data={"url": url}) as response:
response.raise_for_status()
content = await response.text()
return content + "\n\n\n" + REMINDERS
except Exception as error:
return f"Error reading URL: {str(error)}"