diff --git a/comfy_extras/silver_custom.py b/comfy_extras/silver_custom.py index 9bab2fa7e..3d03ee391 100644 --- a/comfy_extras/silver_custom.py +++ b/comfy_extras/silver_custom.py @@ -40,9 +40,7 @@ class Note: class SaveImageList: def __init__(self): current_dir = os.path.abspath(os.getcwd()) - print(current_dir) self.output_dir = os.path.join(current_dir, "output") - print(self.output_dir) self.type = "output" @classmethod diff --git a/server.py b/server.py index 6615a39e4..15bf3be45 100644 --- a/server.py +++ b/server.py @@ -138,6 +138,22 @@ class PromptServer(): return web.Response(status=404) + @routes.post("/delete") + async def delete(request): + current_dir = os.path.abspath(os.getcwd()) + output_dir = os.path.join(current_dir, "output") + if not os.path.exists(output_dir): + return web.json_response({"message": "Output directory does not exist."}, status=404) + try: + for file_name in os.listdir(output_dir): + file_path = os.path.join(output_dir, file_name) + if os.path.isfile(file_path): + os.remove(file_path) + return web.json_response({"message": "All content deleted from Output folder."}, status=200) + + except Exception as e: + return web.json_response({"message": f"An error occurred: {str(e)}"}, status=500) + @routes.get("/prompt") async def get_prompt(request): return web.json_response(self.get_queue_info()) diff --git a/web/scripts/api.js b/web/scripts/api.js index b90b1c656..1e1b6e12d 100644 --- a/web/scripts/api.js +++ b/web/scripts/api.js @@ -106,6 +106,10 @@ class ComfyApi extends EventTarget { return await resp.json(); } + async deleteAllImages() { + await this.#postItem("delete", { delete: "all" }) + } + /** * Gets a list of embedding names * @returns An array of script urls to import diff --git a/web/scripts/ui.js b/web/scripts/ui.js index 58012fe6c..c7bae44ae 100644 --- a/web/scripts/ui.js +++ b/web/scripts/ui.js @@ -329,6 +329,7 @@ export class ComfyUI { $el("button", { textContent: "Load", onclick: () => fileInput.click() }), $el("button", { textContent: "Clear", onclick: () => app.graph.clear() }), $el("button", { textContent: "Load Default", onclick: () => app.loadGraphData() }), + $el("button", { textContent: "Delete Images", onclick: () => api.deleteAllImages() }), ]); this.setStatus({ exec_info: { queue_remaining: "X" } });