fix(frontend): Add Story not Found error page (api side)
This commit is contained in:
+15
-3
@@ -1,6 +1,6 @@
|
||||
from pathlib import Path
|
||||
from fastapi import FastAPI
|
||||
from fastapi.responses import FileResponse, StreamingResponse
|
||||
from fastapi import FastAPI, HTTPException
|
||||
from fastapi.responses import FileResponse, HTMLResponse, StreamingResponse
|
||||
from ebooklib import epub
|
||||
from create_book import retrieve_story, set_cover, set_metadata, add_chapters, slugify
|
||||
import tempfile
|
||||
@@ -22,7 +22,19 @@ async def download_book(story_id: int, download_images: bool = False):
|
||||
book = epub.EpubBook()
|
||||
|
||||
# Metadata and Cover are updated
|
||||
set_metadata(book, data)
|
||||
try:
|
||||
set_metadata(book, data)
|
||||
except KeyError:
|
||||
# raise HTTPException(
|
||||
# status_code=404,
|
||||
# detail='Story not found. Check the ID - Support is available on the <a href="https://discord.gg/P9RHC4KCwd" target="_blank">Discord</a>',
|
||||
# )
|
||||
# return FileResponse(BUILD_PATH / "index.html", status_code=404)
|
||||
return HTMLResponse(
|
||||
status_code=404,
|
||||
content='Story not found. Check the ID - Support is available on the <a href="https://discord.gg/P9RHC4KCwd" target="_blank">Discord</a>',
|
||||
)
|
||||
|
||||
await set_cover(book, data)
|
||||
# print("Metadata Downloaded")
|
||||
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
class:btn-disabled={!story_id}
|
||||
data-umami-event="Download"
|
||||
href={`/download/${story_id}${download_images ? "?download_images=true" : ""}`}
|
||||
download
|
||||
on:click={() => (after_download_page = true)}>Download</a
|
||||
>
|
||||
<label class="cursor-pointer label">
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
<div>
|
||||
<div class="hero min-h-screen">
|
||||
<div
|
||||
class="hero-content flex-col lg:flex-row-reverse glass p-16 rounded shadow-sm"
|
||||
>
|
||||
<div class="text-center max-w-4xl">
|
||||
<h1 class="font-bold text-3xl">
|
||||
Your story was <span
|
||||
class="text-transparent bg-clip-text bg-gradient-to-r to-red-600 via-orange-600 from-red-700"
|
||||
>Not Found</span
|
||||
>
|
||||
</h1>
|
||||
<div class="py-4 space-y-2">
|
||||
<p class="text-2xl">Please check your Story ID.</p>
|
||||
<p class="text-lg pt-2">
|
||||
You can also join us on <a
|
||||
href="https://discord.gg/P9RHC4KCwd"
|
||||
target="_blank"
|
||||
class="link"
|
||||
data-umami-event="Discord">discord</a
|
||||
>, where we release features early and discuss updates.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<a href="/" class="btn btn-primary btn-lg mt-5">Go Home</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user