mirror of
https://github.com/ThePhaseless/Byparr.git
synced 2025-03-15 09:50:20 +08:00
add gracefull errors
This commit is contained in:
parent
24a0271a04
commit
af4750a52a
6
main.py
6
main.py
@ -12,9 +12,7 @@ from src.models.requests import LinkRequest, LinkResponse
|
|||||||
from src.utils import logger
|
from src.utils import logger
|
||||||
from src.utils.browser import bypass_cloudflare, new_browser
|
from src.utils.browser import bypass_cloudflare, new_browser
|
||||||
from src.utils.consts import LOG_LEVEL
|
from src.utils.consts import LOG_LEVEL
|
||||||
from src.utils.extentions import download_extentions
|
|
||||||
|
|
||||||
download_extentions()
|
|
||||||
app = FastAPI(debug=True)
|
app = FastAPI(debug=True)
|
||||||
|
|
||||||
|
|
||||||
@ -32,6 +30,7 @@ async def read_item(request: LinkRequest):
|
|||||||
logger.info(f"Request: {request}")
|
logger.info(f"Request: {request}")
|
||||||
start_time = int(time.time() * 1000)
|
start_time = int(time.time() * 1000)
|
||||||
browser = await new_browser()
|
browser = await new_browser()
|
||||||
|
try:
|
||||||
page = await browser.get(request.url)
|
page = await browser.get(request.url)
|
||||||
await page.bring_to_front()
|
await page.bring_to_front()
|
||||||
|
|
||||||
@ -46,6 +45,9 @@ async def read_item(request: LinkRequest):
|
|||||||
start_timestamp=start_time,
|
start_timestamp=start_time,
|
||||||
challenged=challenged,
|
challenged=challenged,
|
||||||
)
|
)
|
||||||
|
except asyncio.TimeoutError:
|
||||||
|
logger.fatal("Couldn't complete the request")
|
||||||
|
finally:
|
||||||
browser.stop()
|
browser.stop()
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user