diff options
author | huchenlei <chenlei.hu@mail.utoronto.ca> | 2023-07-16 03:43:49 +0000 |
---|---|---|
committer | huchenlei <chenlei.hu@mail.utoronto.ca> | 2023-07-16 03:51:18 +0000 |
commit | 8c11b126e5bd5052154c095177390f249e8e9889 (patch) | |
tree | c0cea7bae4bed9b3258519c7f791587b66d0641d /modules/ui_extra_networks.py | |
parent | 9893d09b4378d14c2a3ef370a5e02b906993ea86 (diff) | |
download | stable-diffusion-webui-gfx803-8c11b126e5bd5052154c095177390f249e8e9889.tar.gz stable-diffusion-webui-gfx803-8c11b126e5bd5052154c095177390f249e8e9889.tar.bz2 stable-diffusion-webui-gfx803-8c11b126e5bd5052154c095177390f249e8e9889.zip |
404 when thumb file not found
Diffstat (limited to 'modules/ui_extra_networks.py')
-rw-r--r-- | modules/ui_extra_networks.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/modules/ui_extra_networks.py b/modules/ui_extra_networks.py index 693cafb6..a2565315 100644 --- a/modules/ui_extra_networks.py +++ b/modules/ui_extra_networks.py @@ -8,6 +8,7 @@ from modules.ui import up_down_symbol import gradio as gr
import json
import html
+from fastapi.exceptions import HTTPException
from modules.generation_parameters_copypaste import image_from_url_text
@@ -26,6 +27,9 @@ def register_page(page): def fetch_file(filename: str = ""):
from starlette.responses import FileResponse
+ if not os.path.isfile(filename):
+ raise HTTPException(status_code=404, detail="File not found")
+
if not any(Path(x).absolute() in Path(filename).absolute().parents for x in allowed_dirs):
raise ValueError(f"File cannot be fetched: {filename}. Must be in one of directories registered by extra pages.")
|