mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-04-18 06:22:44 +08:00
Merge 6284751745 into b615af1c65
This commit is contained in:
commit
febb7b1c84
37
server.py
37
server.py
@ -559,7 +559,7 @@ class PromptServer():
|
|||||||
buffer.seek(0)
|
buffer.seek(0)
|
||||||
|
|
||||||
return web.Response(body=buffer.read(), content_type=f'image/{image_format}',
|
return web.Response(body=buffer.read(), content_type=f'image/{image_format}',
|
||||||
headers={"Content-Disposition": f"filename=\"{filename}\""})
|
headers={"Content-Disposition": f"attachment; filename=\"{filename}\""})
|
||||||
|
|
||||||
if 'channel' not in request.rel_url.query:
|
if 'channel' not in request.rel_url.query:
|
||||||
channel = 'rgba'
|
channel = 'rgba'
|
||||||
@ -579,7 +579,7 @@ class PromptServer():
|
|||||||
buffer.seek(0)
|
buffer.seek(0)
|
||||||
|
|
||||||
return web.Response(body=buffer.read(), content_type='image/png',
|
return web.Response(body=buffer.read(), content_type='image/png',
|
||||||
headers={"Content-Disposition": f"filename=\"{filename}\""})
|
headers={"Content-Disposition": f"attachment; filename=\"{filename}\""})
|
||||||
|
|
||||||
elif channel == 'a':
|
elif channel == 'a':
|
||||||
with Image.open(file) as img:
|
with Image.open(file) as img:
|
||||||
@ -596,7 +596,7 @@ class PromptServer():
|
|||||||
alpha_buffer.seek(0)
|
alpha_buffer.seek(0)
|
||||||
|
|
||||||
return web.Response(body=alpha_buffer.read(), content_type='image/png',
|
return web.Response(body=alpha_buffer.read(), content_type='image/png',
|
||||||
headers={"Content-Disposition": f"filename=\"{filename}\""})
|
headers={"Content-Disposition": f"attachment; filename=\"{filename}\""})
|
||||||
else:
|
else:
|
||||||
# Use the content type from asset resolution if available,
|
# Use the content type from asset resolution if available,
|
||||||
# otherwise guess from the filename.
|
# otherwise guess from the filename.
|
||||||
@ -613,7 +613,7 @@ class PromptServer():
|
|||||||
return web.FileResponse(
|
return web.FileResponse(
|
||||||
file,
|
file,
|
||||||
headers={
|
headers={
|
||||||
"Content-Disposition": f"filename=\"{filename}\"",
|
"Content-Disposition": f"attachment; filename=\"{filename}\"",
|
||||||
"Content-Type": content_type
|
"Content-Type": content_type
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -1257,32 +1257,3 @@ class PromptServer():
|
|||||||
address_print = address
|
address_print = address
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
logging.info("To see the GUI go to: {}://{}:{}".format(scheme, address_print, port))
|
|
||||||
|
|
||||||
if call_on_start is not None:
|
|
||||||
call_on_start(scheme, self.address, self.port)
|
|
||||||
|
|
||||||
def add_on_prompt_handler(self, handler):
|
|
||||||
self.on_prompt_handlers.append(handler)
|
|
||||||
|
|
||||||
def trigger_on_prompt(self, json_data):
|
|
||||||
for handler in self.on_prompt_handlers:
|
|
||||||
try:
|
|
||||||
json_data = handler(json_data)
|
|
||||||
except Exception:
|
|
||||||
logging.warning("[ERROR] An error occurred during the on_prompt_handler processing")
|
|
||||||
logging.warning(traceback.format_exc())
|
|
||||||
|
|
||||||
return json_data
|
|
||||||
|
|
||||||
def send_progress_text(
|
|
||||||
self, text: Union[bytes, bytearray, str], node_id: str, sid=None
|
|
||||||
):
|
|
||||||
if isinstance(text, str):
|
|
||||||
text = text.encode("utf-8")
|
|
||||||
node_id_bytes = str(node_id).encode("utf-8")
|
|
||||||
|
|
||||||
# Pack the node_id length as a 4-byte unsigned integer, followed by the node_id bytes
|
|
||||||
message = struct.pack(">I", len(node_id_bytes)) + node_id_bytes + text
|
|
||||||
|
|
||||||
self.send_sync(BinaryEventTypes.TEXT, message, sid)
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user