添加密码
This commit is contained in:
+11
-6
@@ -29,6 +29,11 @@ COMFYUI_URL = "http://112.126.94.241:28188"
|
||||
COMFYUI_URL_BACKUP = "http://112.126.94.241:38188"
|
||||
WORKFLOW_PATH = Path(__file__).parent / "change1.json"
|
||||
|
||||
_cred_dir = Path(__file__).parent.parent
|
||||
COMFYUI_USER = (_cred_dir / "user.txt").read_text(encoding="utf-8").strip()
|
||||
COMFYUI_PASS = (_cred_dir / "password.txt").read_text(encoding="utf-8").strip()
|
||||
COMFYUI_AUTH = (COMFYUI_USER, COMFYUI_PASS)
|
||||
|
||||
NODE_MODEL = "11" # 输入图(LoadImage)
|
||||
NODE_OUTPUT = "33" # 输出(SaveImage)
|
||||
NODE_PROMPT = "31" # 文本提示(PrimitiveStringMultiline)
|
||||
@@ -82,11 +87,11 @@ def decode_base64_image(b64_str: str) -> bytes:
|
||||
|
||||
|
||||
async def check_comfyui_alive(base_url: str, timeout: float = 3.0) -> bool:
|
||||
"""检查指定的 ComfyUI 服务器是否可用"""
|
||||
"""检查指定的 ComfyUI 服务器是否可用(能连通且非 5xx 即视为可用)"""
|
||||
try:
|
||||
async with httpx.AsyncClient(timeout=timeout) as client:
|
||||
async with httpx.AsyncClient(timeout=timeout, auth=COMFYUI_AUTH) as client:
|
||||
resp = await client.get(f"{base_url}/system_stats")
|
||||
return resp.status_code == 200
|
||||
return resp.status_code < 500
|
||||
except Exception as e:
|
||||
print(f"ComfyUI 健康检查失败 {base_url}: {e}")
|
||||
return False
|
||||
@@ -169,7 +174,7 @@ async def try_on(req: TryOnRequest):
|
||||
if desc:
|
||||
workflow[NODE_PROMPT]["inputs"] = {"value": desc}
|
||||
|
||||
async with httpx.AsyncClient(timeout=60.0) as client:
|
||||
async with httpx.AsyncClient(timeout=60.0, auth=COMFYUI_AUTH) as client:
|
||||
try:
|
||||
model_bytes = decode_base64_image(req.model_image)
|
||||
except Exception as e:
|
||||
@@ -190,7 +195,7 @@ async def try_on(req: TryOnRequest):
|
||||
except httpx.HTTPError as e:
|
||||
raise HTTPException(status_code=502, detail=f"提交工作流失败: {e}")
|
||||
|
||||
async with httpx.AsyncClient(timeout=30.0) as poll_client:
|
||||
async with httpx.AsyncClient(timeout=30.0, auth=COMFYUI_AUTH) as poll_client:
|
||||
outputs = await wait_for_result(poll_client, comfyui_url, prompt_id, timeout=300)
|
||||
|
||||
node_output = outputs.get(NODE_OUTPUT)
|
||||
@@ -206,7 +211,7 @@ async def try_on(req: TryOnRequest):
|
||||
subfolder = img_info.get("subfolder", "")
|
||||
type_ = img_info.get("type", "output")
|
||||
|
||||
async with httpx.AsyncClient(timeout=30.0) as dl_client:
|
||||
async with httpx.AsyncClient(timeout=30.0, auth=COMFYUI_AUTH) as dl_client:
|
||||
result_bytes = await fetch_image_bytes(dl_client, comfyui_url, filename, subfolder, type_)
|
||||
|
||||
suffix = Path(filename).suffix or ".png"
|
||||
|
||||
+11
-6
@@ -31,6 +31,11 @@ COMFYUI_URL = "http://112.126.94.241:28188"
|
||||
COMFYUI_URL_BACKUP = "http://112.126.94.241:38188"
|
||||
WORKFLOW_PATH = Path(__file__).parent / "change2_1_ex.json"
|
||||
|
||||
_cred_dir = Path(__file__).parent.parent
|
||||
COMFYUI_USER = (_cred_dir / "user.txt").read_text(encoding="utf-8").strip()
|
||||
COMFYUI_PASS = (_cred_dir / "password.txt").read_text(encoding="utf-8").strip()
|
||||
COMFYUI_AUTH = (COMFYUI_USER, COMFYUI_PASS)
|
||||
|
||||
# WORKFLOW_PATH = Path(__file__).parent / "change_fast2.json"
|
||||
|
||||
# 节点 ID 映射
|
||||
@@ -99,11 +104,11 @@ def decode_base64_image(b64_str: str) -> bytes:
|
||||
|
||||
|
||||
async def check_comfyui_alive(base_url: str, timeout: float = 3.0) -> bool:
|
||||
"""检查指定的 ComfyUI 服务器是否可用"""
|
||||
"""检查指定的 ComfyUI 服务器是否可用(能连通且非 5xx 即视为可用)"""
|
||||
try:
|
||||
async with httpx.AsyncClient(timeout=timeout) as client:
|
||||
async with httpx.AsyncClient(timeout=timeout, auth=COMFYUI_AUTH) as client:
|
||||
resp = await client.get(f"{base_url}/system_stats")
|
||||
return resp.status_code == 200
|
||||
return resp.status_code < 500
|
||||
except Exception as e:
|
||||
print(f"ComfyUI 健康检查失败 {base_url}: {e}")
|
||||
return False
|
||||
@@ -187,7 +192,7 @@ async def try_on(req: TryOnRequest):
|
||||
if desc:
|
||||
workflow[NODE_PROMPT]["inputs"] = {"value": desc}
|
||||
|
||||
async with httpx.AsyncClient(timeout=60.0) as client:
|
||||
async with httpx.AsyncClient(timeout=60.0, auth=COMFYUI_AUTH) as client:
|
||||
try:
|
||||
model_bytes = decode_base64_image(req.model_image)
|
||||
shirt_bytes = decode_base64_image(req.shirt_image)
|
||||
@@ -214,7 +219,7 @@ async def try_on(req: TryOnRequest):
|
||||
except httpx.HTTPError as e:
|
||||
raise HTTPException(status_code=502, detail=f"提交工作流失败: {e}")
|
||||
|
||||
async with httpx.AsyncClient(timeout=30.0) as poll_client:
|
||||
async with httpx.AsyncClient(timeout=30.0, auth=COMFYUI_AUTH) as poll_client:
|
||||
outputs = await wait_for_result(poll_client, comfyui_url, prompt_id, timeout=300)
|
||||
|
||||
node_output = outputs.get(NODE_OUTPUT)
|
||||
@@ -230,7 +235,7 @@ async def try_on(req: TryOnRequest):
|
||||
subfolder = img_info.get("subfolder", "")
|
||||
type_ = img_info.get("type", "output")
|
||||
|
||||
async with httpx.AsyncClient(timeout=30.0) as dl_client:
|
||||
async with httpx.AsyncClient(timeout=30.0, auth=COMFYUI_AUTH) as dl_client:
|
||||
result_bytes = await fetch_image_bytes(dl_client, comfyui_url, filename, subfolder, type_)
|
||||
|
||||
# 缩放到 768x1024
|
||||
|
||||
+11
-6
@@ -30,6 +30,11 @@ COMFYUI_URL = "http://112.126.94.241:28188"
|
||||
COMFYUI_URL_BACKUP = "http://112.126.94.241:38188"
|
||||
WORKFLOW_PATH = Path(__file__).parent / "change2_2_0308.json"
|
||||
|
||||
_cred_dir = Path(__file__).parent.parent
|
||||
COMFYUI_USER = (_cred_dir / "user.txt").read_text(encoding="utf-8").strip()
|
||||
COMFYUI_PASS = (_cred_dir / "password.txt").read_text(encoding="utf-8").strip()
|
||||
COMFYUI_AUTH = (COMFYUI_USER, COMFYUI_PASS)
|
||||
|
||||
# WORKFLOW_PATH = Path(__file__).parent / "change_fast3.json"
|
||||
|
||||
# 节点 ID 映射
|
||||
@@ -90,11 +95,11 @@ def decode_base64_image(b64_str: str) -> bytes:
|
||||
|
||||
|
||||
async def check_comfyui_alive(base_url: str, timeout: float = 3.0) -> bool:
|
||||
"""检查指定的 ComfyUI 服务器是否可用"""
|
||||
"""检查指定的 ComfyUI 服务器是否可用(能连通且非 5xx 即视为可用)"""
|
||||
try:
|
||||
async with httpx.AsyncClient(timeout=timeout) as client:
|
||||
async with httpx.AsyncClient(timeout=timeout, auth=COMFYUI_AUTH) as client:
|
||||
resp = await client.get(f"{base_url}/system_stats")
|
||||
return resp.status_code == 200
|
||||
return resp.status_code < 500
|
||||
except Exception as e:
|
||||
print(f"ComfyUI 健康检查失败 {base_url}: {e}")
|
||||
return False
|
||||
@@ -178,7 +183,7 @@ async def try_on(req: TryOnRequest):
|
||||
if desc:
|
||||
workflow[NODE_PROMPT]["inputs"] = {"value": desc}
|
||||
|
||||
async with httpx.AsyncClient(timeout=60.0) as client:
|
||||
async with httpx.AsyncClient(timeout=60.0, auth=COMFYUI_AUTH) as client:
|
||||
try:
|
||||
model_bytes = decode_base64_image(req.model_image)
|
||||
shirt_bytes = decode_base64_image(req.shirt_image)
|
||||
@@ -209,7 +214,7 @@ async def try_on(req: TryOnRequest):
|
||||
except httpx.HTTPError as e:
|
||||
raise HTTPException(status_code=502, detail=f"提交工作流失败: {e}")
|
||||
|
||||
async with httpx.AsyncClient(timeout=30.0) as poll_client:
|
||||
async with httpx.AsyncClient(timeout=30.0, auth=COMFYUI_AUTH) as poll_client:
|
||||
outputs = await wait_for_result(poll_client, comfyui_url, prompt_id, timeout=300)
|
||||
|
||||
node_output = outputs.get(NODE_OUTPUT)
|
||||
@@ -225,7 +230,7 @@ async def try_on(req: TryOnRequest):
|
||||
subfolder = img_info.get("subfolder", "")
|
||||
type_ = img_info.get("type", "output")
|
||||
|
||||
async with httpx.AsyncClient(timeout=30.0) as dl_client:
|
||||
async with httpx.AsyncClient(timeout=30.0, auth=COMFYUI_AUTH) as dl_client:
|
||||
result_bytes = await fetch_image_bytes(dl_client, comfyui_url, filename, subfolder, type_)
|
||||
|
||||
# 缩放到 768x1024
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
your888password
|
||||
Reference in New Issue
Block a user