mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-04-20 03:13:30 +00:00
serve workflow templates from custom_nodes
This commit is contained in:
parent
b6e3bc2451
commit
547eb21d06
5
nodes.py
5
nodes.py
@ -2033,6 +2033,9 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
|
||||
EXTENSION_WEB_DIRS = {}
|
||||
|
||||
# Dictionary of successfully loaded module names and associated directories.
|
||||
LOADED_MODULE_DIRS = {}
|
||||
|
||||
|
||||
def get_module_name(module_path: str) -> str:
|
||||
"""
|
||||
@ -2074,6 +2077,8 @@ def load_custom_node(module_path: str, ignore=set(), module_parent="custom_nodes
|
||||
sys.modules[module_name] = module
|
||||
module_spec.loader.exec_module(module)
|
||||
|
||||
LOADED_MODULE_DIRS[module_name] = os.path.abspath(module_dir)
|
||||
|
||||
if hasattr(module, "WEB_DIRECTORY") and getattr(module, "WEB_DIRECTORY") is not None:
|
||||
web_dir = os.path.abspath(os.path.join(module_dir, getattr(module, "WEB_DIRECTORY")))
|
||||
if os.path.isdir(web_dir):
|
||||
|
@ -723,6 +723,13 @@ class PromptServer():
|
||||
self.app.add_routes(api_routes)
|
||||
self.app.add_routes(self.routes)
|
||||
|
||||
# Add routes for workflow templates in custom nodes.
|
||||
for module_name, module_dir in nodes.LOADED_MODULE_DIRS.items():
|
||||
workflows_dir = os.path.join(module_dir, 'example_workflows')
|
||||
if os.path.exists(workflows_dir):
|
||||
self.app.add_routes([web.static('/workflow_templates/' + module_name, workflows_dir)])
|
||||
|
||||
# Add routes from web extensions.
|
||||
for name, dir in nodes.EXTENSION_WEB_DIRS.items():
|
||||
self.app.add_routes([web.static('/extensions/' + name, dir)])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user