File size: 1,706 Bytes
2a261b0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | """ComfyUI entry point. A1111 / Forge / reForge load scripts/ instead and never import this."""
import os
from .comfy_nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
from .text_fix import web
# The page script that puts the "Open editor" button on the node. The editor's own files are
# served by a route (see web.register_aiohttp), not from this folder.
WEB_DIRECTORY = "./comfy_web"
class ComfyHost(web.Host):
"""ComfyUI: the model pass is the workflow's, a processed folder goes to its output folder."""
def output_folder(self):
try:
import folder_paths
return folder_paths.get_output_directory()
except ImportError:
return web.Host.output_folder(self)
def model_dir(self):
try:
import folder_paths
return os.path.join(folder_paths.models_dir, "text_fix")
except ImportError:
return web.Host.model_dir(self)
def allows_folders(self):
try:
from comfy.cli_args import args
except ImportError:
return False
listen = str(getattr(args, "listen", "127.0.0.1") or "127.0.0.1")
return all(part.strip() in ("127.0.0.1", "localhost", "::1") for part in listen.split(","))
try:
from server import PromptServer
except ImportError: # imported outside ComfyUI (tests): the node works, the editor has no server
PromptServer = None
if PromptServer is not None and getattr(PromptServer, "instance", None) is not None:
web.register_aiohttp(PromptServer.instance.routes, ComfyHost())
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"]
|