Extract server route payload handlers
This commit is contained in:
+17
-44
@@ -397,10 +397,6 @@ try:
|
||||
from .loop_nodes import (
|
||||
LOOP_NODE_CLASS_MAPPINGS,
|
||||
LOOP_NODE_DISPLAY_NAME_MAPPINGS,
|
||||
accumulator_delete_entries,
|
||||
accumulator_list_entries,
|
||||
accumulator_move_entry,
|
||||
accumulator_save_entries,
|
||||
)
|
||||
from .node_camera import (
|
||||
NODE_CLASS_MAPPINGS as CAMERA_NODE_CLASS_MAPPINGS,
|
||||
@@ -438,17 +434,17 @@ try:
|
||||
NODE_CLASS_MAPPINGS as SEED_RESOLUTION_NODE_CLASS_MAPPINGS,
|
||||
NODE_DISPLAY_NAME_MAPPINGS as SEED_RESOLUTION_NODE_DISPLAY_NAME_MAPPINGS,
|
||||
)
|
||||
from .prompt_builder import (
|
||||
save_character_profile_payload,
|
||||
from .server_routes import (
|
||||
accumulator_delete_payload,
|
||||
accumulator_list_payload,
|
||||
accumulator_move_payload,
|
||||
accumulator_save_payload,
|
||||
profile_save_cached_payload,
|
||||
)
|
||||
except ImportError:
|
||||
from loop_nodes import (
|
||||
LOOP_NODE_CLASS_MAPPINGS,
|
||||
LOOP_NODE_DISPLAY_NAME_MAPPINGS,
|
||||
accumulator_delete_entries,
|
||||
accumulator_list_entries,
|
||||
accumulator_move_entry,
|
||||
accumulator_save_entries,
|
||||
)
|
||||
from node_camera import (
|
||||
NODE_CLASS_MAPPINGS as CAMERA_NODE_CLASS_MAPPINGS,
|
||||
@@ -486,8 +482,12 @@ except ImportError:
|
||||
NODE_CLASS_MAPPINGS as SEED_RESOLUTION_NODE_CLASS_MAPPINGS,
|
||||
NODE_DISPLAY_NAME_MAPPINGS as SEED_RESOLUTION_NODE_DISPLAY_NAME_MAPPINGS,
|
||||
)
|
||||
from prompt_builder import (
|
||||
save_character_profile_payload,
|
||||
from server_routes import (
|
||||
accumulator_delete_payload,
|
||||
accumulator_list_payload,
|
||||
accumulator_move_payload,
|
||||
accumulator_save_payload,
|
||||
profile_save_cached_payload,
|
||||
)
|
||||
|
||||
|
||||
@@ -496,10 +496,7 @@ if PromptServer is not None and web is not None:
|
||||
async def sxcp_save_cached_profile(request):
|
||||
try:
|
||||
payload = await request.json()
|
||||
result = save_character_profile_payload(
|
||||
profile_name=str(payload.get("profile_name") or ""),
|
||||
profile_json=payload.get("profile_json") or "",
|
||||
)
|
||||
result = profile_save_cached_payload(payload)
|
||||
return web.json_response(result)
|
||||
except Exception as exc:
|
||||
return web.json_response({"error": str(exc)}, status=400)
|
||||
@@ -508,10 +505,7 @@ if PromptServer is not None and web is not None:
|
||||
async def sxcp_accumulator_list(request):
|
||||
try:
|
||||
payload = await request.json()
|
||||
result = accumulator_list_entries(
|
||||
str(payload.get("store_key") or ""),
|
||||
preview_limit=int(payload.get("preview_limit") or 0),
|
||||
)
|
||||
result = accumulator_list_payload(payload)
|
||||
return web.json_response(result)
|
||||
except Exception as exc:
|
||||
return web.json_response({"error": str(exc)}, status=400)
|
||||
@@ -520,14 +514,7 @@ if PromptServer is not None and web is not None:
|
||||
async def sxcp_accumulator_delete(request):
|
||||
try:
|
||||
payload = await request.json()
|
||||
result = accumulator_delete_entries(
|
||||
store_key=str(payload.get("store_key") or ""),
|
||||
preview_key=str(payload.get("preview_key") or ""),
|
||||
entry_id=str(payload.get("entry_id") or ""),
|
||||
index=int(payload.get("index") or 0),
|
||||
clear=bool(payload.get("clear")),
|
||||
preview_limit=int(payload.get("preview_limit") or 0),
|
||||
)
|
||||
result = accumulator_delete_payload(payload)
|
||||
return web.json_response(result)
|
||||
except Exception as exc:
|
||||
return web.json_response({"error": str(exc)}, status=400)
|
||||
@@ -536,13 +523,7 @@ if PromptServer is not None and web is not None:
|
||||
async def sxcp_accumulator_save(request):
|
||||
try:
|
||||
payload = await request.json()
|
||||
result = accumulator_save_entries(
|
||||
store_key=str(payload.get("store_key") or ""),
|
||||
save_path=str(payload.get("save_path") or "sxcp_accumulator"),
|
||||
filename_prefix=str(payload.get("filename_prefix") or "sxcp_accum"),
|
||||
clear_after_save=bool(payload.get("clear_after_save")),
|
||||
preview_limit=int(payload.get("preview_limit") or 0),
|
||||
)
|
||||
result = accumulator_save_payload(payload)
|
||||
return web.json_response(result)
|
||||
except Exception as exc:
|
||||
return web.json_response({"error": str(exc)}, status=400)
|
||||
@@ -551,15 +532,7 @@ if PromptServer is not None and web is not None:
|
||||
async def sxcp_accumulator_move(request):
|
||||
try:
|
||||
payload = await request.json()
|
||||
result = accumulator_move_entry(
|
||||
store_key=str(payload.get("store_key") or ""),
|
||||
preview_key=str(payload.get("preview_key") or ""),
|
||||
entry_id=str(payload.get("entry_id") or ""),
|
||||
index=int(payload.get("index") or 0),
|
||||
direction=str(payload.get("direction") or "up"),
|
||||
target_index=int(payload.get("target_index") or 0),
|
||||
preview_limit=int(payload.get("preview_limit") or 0),
|
||||
)
|
||||
result = accumulator_move_payload(payload)
|
||||
return web.json_response(result)
|
||||
except Exception as exc:
|
||||
return web.json_response({"error": str(exc)}, status=400)
|
||||
|
||||
Reference in New Issue
Block a user