diff --git a/sdppp_python/apis.py b/sdppp_python/apis.py index fce8ab3..29b5b23 100644 --- a/sdppp_python/apis.py +++ b/sdppp_python/apis.py @@ -6,6 +6,7 @@ except ImportError: print("SD-PPP: fastapi not found") try: from aiohttp import web + from aiohttp.web import static except ImportError: print("SD-PPP: aiohttp not found") @@ -14,8 +15,9 @@ from io import BytesIO from PIL import Image from .protocols.photoshop import ProtocolPhotoshop import json -import folder_paths -import os + +import os.path as path +projectRoot = path.dirname(path.dirname(__file__)) # str => PIL.Image image_cache = dict() @@ -33,6 +35,10 @@ def addImageCache(image, name = ''): def registerComfyHTTPEndpoints(sdppp, PromptServer): + @PromptServer.instance.routes.get('/sd-ppp-static/{tail:.*}') + async def sdppp_static(request): + return web.FileResponse(path.join(projectRoot, 'plugins', request.match_info['tail'])) + @PromptServer.instance.routes.get('/sdppp_download') async def sdppp_download(request): try: diff --git a/sdppp_python/sdppp.py b/sdppp_python/sdppp.py index 1b8c93c..2350909 100644 --- a/sdppp_python/sdppp.py +++ b/sdppp_python/sdppp.py @@ -35,12 +35,6 @@ class SDPPP: registerComfyHTTPEndpoints(self, PromptServer) self.server_type = "comfy" - # serve static - PromptServer.instance.app.router.add_static( - '/sd-ppp-static', - path.join(projectRoot, 'plugins'), - show_index=True # Enable directory listing - ) def attach_to_SD(self, app): self.sio = socketio.AsyncServer(