fix(nodes): fix bugs with serving images

When returning a `FileResponse`, we must provide a valid path, else an exception is raised outside the route handler.

Add the `validate_path` method back to the service so we can validate paths before returning the file.

I don't like this but apparently this is just how `starlette` and `fastapi` works with `FileResponse`.
This commit is contained in:
psychedelicious
2023-05-23 22:57:29 +10:00
committed by Kent Keirsey
parent 4c331a5d7e
commit 23d9d58c08
5 changed files with 53 additions and 11 deletions

View File

@ -3,8 +3,7 @@ import asyncio
from inspect import signature
import uvicorn
from invokeai.app.models import resources
import invokeai.backend.util.logging as logger
from invokeai.backend.util.logging import InvokeAILogger
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.openapi.docs import get_redoc_html, get_swagger_ui_html
@ -20,6 +19,7 @@ from .api.sockets import SocketIO
from .invocations.baseinvocation import BaseInvocation
from .services.config import InvokeAIAppConfig
logger = InvokeAILogger.getLogger()
# Create the app
# TODO: create this all in a method so configuration/etc. can be passed in?