import os from aiohttp import web from server import PromptServer _PKG_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) _ASSETS = os.path.join(_PKG_ROOT, "assets") _PREFERRED = ("BONSO_TOOLS.png", "bonso_tools.png", "icon.png") def find_icon(): for name in _PREFERRED: path = os.path.join(_ASSETS, name) if os.path.isfile(path): return path try: for name in sorted(os.listdir(_ASSETS)): low = name.lower() if low.endswith(".png") and ("bonso" in low or "icon" in low): return os.path.join(_ASSETS, name) except OSError: pass return None @PromptServer.instance.routes.get("/bonso/brand_icon.png") async def brand_icon(request): path = find_icon() if not path: return web.json_response( {"error": "No Bonso Tools icon found in assets/."}, status=404) return web.FileResponse(path, headers={"Cache-Control": "max-age=86400"}) NODE_CLASS_MAPPINGS = {} NODE_DISPLAY_NAME_MAPPINGS = {}