This commit is contained in:
noembryo
2026-01-14 21:09:55 +02:00
parent 1d3b07eea5
commit 8a8195738f
5 changed files with 371 additions and 65 deletions
+41 -6
View File
@@ -10,18 +10,23 @@ import os
import io
from os.path import isfile, join, isdir
import importlib
from .nodes import LISTS_PATH, __author__, __version__
from aiohttp import web
from server import PromptServer
from .nodes import LISTS_PATH, JsonPromptLoader, __author__, __version__
print(f"### Loading: {__author__} nodes v{__version__}")
WEB_DIRECTORY = "./web/js"
NODE_CLASS_MAPPINGS = {}
NODE_DISPLAY_NAME_MAPPINGS = {}
node_list = [
"nodes",
# "load_image_from_dir",
]
NODE_CLASS_MAPPINGS = {}
NODE_DISPLAY_NAME_MAPPINGS = {}
for module_name in node_list:
imported_module = importlib.import_module(".{}".format(module_name), __name__)
@@ -35,9 +40,39 @@ for i in range(6): # create TermList1-6 if not exists
file_name = join(LISTS_PATH, "TermList{}.json".format(i + 1))
if not isfile(file_name):
with io.open(file_name, "w+", encoding="utf-8", newline="\n") as f:
# noinspection PyTypeChecker
json.dump({"None": ""}, f, indent=4)
WEB_DIRECTORY = "./web"
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS",
"WEB_DIRECTORY",
"WEB_DIRECTORY", "setup",
]
# Add custom route for JSON loading
try:
@PromptServer.instance.routes.get('/noembryo/get_json')
async def get_json(request):
path = request.query.get('path', '')
if path:
try:
with open(path, 'r', encoding='utf-8') as f:
data = json.load(f)
JsonPromptLoader.load_data(path) # Update Python data
return web.json_response(data)
except Exception as e:
return web.json_response({"error": str(e)})
return web.json_response({})
except ImportError:
pass # Server not available
# def setup():
# @PromptServer.instance.routes.get('/noembryo/get_json')
# async def get_json(request):
# path = request.query.get('path', '')
# if path:
# try:
# with open(path, 'r', encoding='utf-8') as f:
# data = json.load(f)
# return web.json_response(data)
# except Exception as e:
# return web.json_response({"error": str(e)})
# return web.json_response({})