feat(api): Add rate-limiting error message
This commit is contained in:
@@ -16,6 +16,7 @@ from create_book import (
|
|||||||
import tempfile
|
import tempfile
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
|
from aiohttp import ClientResponseError
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
BUILD_PATH = Path(__file__).parent / "build"
|
BUILD_PATH = Path(__file__).parent / "build"
|
||||||
@@ -107,6 +108,13 @@ async def handle_download(
|
|||||||
content='The story you tried to download does not exist or has been deleted. Support is available on the <a href="https://discord.gg/P9RHC4KCwd" target="_blank">Discord</a>',
|
content='The story you tried to download does not exist or has been deleted. Support is available on the <a href="https://discord.gg/P9RHC4KCwd" target="_blank">Discord</a>',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
except ClientResponseError:
|
||||||
|
# Rate-limit by Wattpad
|
||||||
|
return HTMLResponse(
|
||||||
|
status_code=429,
|
||||||
|
content='Unfortunately, the downloader got rate-limited by Wattpad. Please try again later. Support is available on the <a href="https://discord.gg/P9RHC4KCwd" target="_blank">Discord</a>',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
app.mount("/", StaticFiles(directory=BUILD_PATH), "static")
|
app.mount("/", StaticFiles(directory=BUILD_PATH), "static")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user