mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-01-11 02:15:17 +00:00
delete-file
endpoint remove
This commit is contained in:
parent
59844491b1
commit
fa2c56ac60
26
server.py
26
server.py
@ -413,32 +413,6 @@ class PromptServer():
|
||||
|
||||
return image_upload(post, image_save_function)
|
||||
|
||||
@routes.delete("/delete-file")
|
||||
async def delete_file(request):
|
||||
type = request.query.get("type")
|
||||
if not type:
|
||||
return web.Response(text="Need Type",status=400)
|
||||
|
||||
filename = request.query.get("file_name")
|
||||
if not filename:
|
||||
return web.Response(text="Need Filename",status=400)
|
||||
|
||||
sub = request.query.get("subfolder","")
|
||||
|
||||
if sub == "":
|
||||
file_path = os.path.join(os.getcwd(),type,filename)
|
||||
else:
|
||||
file_path = os.path.join(os.getcwd(),type,sub,filename)
|
||||
|
||||
if not os.path.isfile(file_path):
|
||||
return web.Response(text="Not Found File", status=404)
|
||||
|
||||
try:
|
||||
os.remove(file_path)
|
||||
return web.Response(text=f"Success Remove File : {file_path[len(os.getcwd())+1:]}",status=200)
|
||||
except Exception as e:
|
||||
return web.Response(text=f"Failed Remove File\n{str(e)}",status=500)
|
||||
|
||||
@routes.get("/view")
|
||||
async def view_image(request):
|
||||
if "filename" in request.rel_url.query:
|
||||
|
Loading…
Reference in New Issue
Block a user