Download custom_nodes/ComfyUI-to-Python-Extension/__init__.py from fotographerai/Zen-Style-Shape: direct link, hf CLI and curl.
- Browser
- Download file 1.36 kB
-
https://huggingface.co/spaces/fotographerai/Zen-Style-Shape/resolve/1e1fbeb6135765d0be77b04237eb90cd6ba0d1a0/custom_nodes/ComfyUI-to-Python-Extension/__init__.py
- Command line
-
hf download hf://spaces/fotographerai/Zen-Style-Shape@1e1fbeb6135765d0be77b04237eb90cd6ba0d1a0/custom_nodes/ComfyUI-to-Python-Extension/__init__.py
-
curl -L -o __init__.py https://huggingface.co/spaces/fotographerai/Zen-Style-Shape/resolve/1e1fbeb6135765d0be77b04237eb90cd6ba0d1a0/custom_nodes/ComfyUI-to-Python-Extension/__init__.py
1.36 kB
| import sys | |
| import os | |
| from io import StringIO | |
| import traceback | |
| from aiohttp import web | |
| ext_dir = os.path.dirname(__file__) | |
| sys.path.append(ext_dir) | |
| try: | |
| import black | |
| except ImportError: | |
| print("Unable to import requirements for ComfyUI-SaveAsScript.") | |
| print("Installing...") | |
| import importlib | |
| spec = importlib.util.spec_from_file_location( | |
| "impact_install", os.path.join(os.path.dirname(__file__), "install.py") | |
| ) | |
| impact_install = importlib.util.module_from_spec(spec) | |
| spec.loader.exec_module(impact_install) | |
| print("Successfully installed. Hopefully, at least.") | |
| # Prevent reimporting of custom nodes | |
| os.environ["RUNNING_IN_COMFYUI"] = "TRUE" | |
| from comfyui_to_python import ComfyUItoPython | |
| sys.path.append(os.path.dirname(os.path.dirname(ext_dir))) | |
| import server | |
| WEB_DIRECTORY = "js" | |
| NODE_CLASS_MAPPINGS = {} | |
| async def save_as_script(request): | |
| try: | |
| data = await request.json() | |
| name = data["name"] | |
| workflow = data["workflow"] | |
| sio = StringIO() | |
| ComfyUItoPython(workflow=workflow, output_file=sio) | |
| sio.seek(0) | |
| data = sio.read() | |
| return web.Response(text=data, status=200) | |
| except Exception as e: | |
| traceback.print_exc() | |
| return web.Response(text=str(e), status=500) | |