rogerxavier
commited on
Commit
•
8cea993
1
Parent(s):
6bd6492
Update api.py
Browse files
api.py
CHANGED
@@ -56,11 +56,18 @@ def getOriginalMangaList(images: List[UploadFile] = File(...), save_path: str =
|
|
56 |
|
57 |
##这个比较快不用异步
|
58 |
@app.delete("/deleteFiles")
|
59 |
-
async def
|
60 |
-
for
|
61 |
-
|
62 |
-
|
|
|
63 |
os.remove(file_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
return {"message": f"成功删除{directory}目录下的所有文件"}
|
65 |
##这个比较快不用异步
|
66 |
|
|
|
56 |
|
57 |
##这个比较快不用异步
|
58 |
@app.delete("/deleteFiles")
|
59 |
+
async def delete_all_files_and_folders(directory:str):
|
60 |
+
for root, dirs, files in os.walk(directory, topdown=False):
|
61 |
+
for name in files:
|
62 |
+
file_path = os.path.join(root, name)
|
63 |
+
print("删除指定目录函数检查到文件,删除文件:", file_path)
|
64 |
os.remove(file_path)
|
65 |
+
for name in dirs:
|
66 |
+
dir_path = os.path.join(root, name)
|
67 |
+
print("删除指定目录函数检查到目录,删除目录:", dir_path)
|
68 |
+
os.rmdir(dir_path)
|
69 |
+
# 删除根目录
|
70 |
+
os.rmdir(directory)
|
71 |
return {"message": f"成功删除{directory}目录下的所有文件"}
|
72 |
##这个比较快不用异步
|
73 |
|