Skip to content

Commit

Permalink
refactor: use Node static methods to handle widget values
Browse files Browse the repository at this point in the history
  • Loading branch information
mus-taches committed Nov 15, 2024
1 parent 6d01bc9 commit 7a6085d
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions py/cozy_spoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
# https://github.com/cozy-comfyui/cozy_spoke

import time
import toml
from pathlib import Path
# import toml
# from pathlib import Path
from typing import Any
from aiohttp import web
from aiohttp import web # , ClientSession
from server import PromptServer

from .node import Node

EVENT_COZY_UPDATE = "cozy-event-combo-update"


Expand Down Expand Up @@ -40,17 +42,7 @@ def poll(cls, ident, period=0.01, timeout=3) -> Any:

def initialize_cozy_spoke():

# Load action config data
path = Path(__file__).parent.parent / "config/actions.toml"

try:
with open(path) as file:
data = toml.load(file)
except Exception:
print(f"Error loading {path}")
data = {}

# Define routes
data = Node.load_data("actions.toml")

@PromptServer.instance.routes.get("/cozy_spoke")
async def route_cozy_spoke(request) -> Any:
Expand Down Expand Up @@ -85,7 +77,8 @@ async def route_cozy_spoke_update(request) -> Any:
result = {}
if (response := json_data.get("data")) is not None:
acts = data["nsfw"]["acts"]
result = {'data': acts.get(response.lower(),
[])}
selected_acts = acts.get(response.lower(), [])
inputs = Node.build_inputs_list(selected_acts)
result = {'data': inputs}

return web.json_response(result)

0 comments on commit 7a6085d

Please sign in to comment.