Skip to content

Commit

Permalink
feat: add a server endpoint to delete files
Browse files Browse the repository at this point in the history
  • Loading branch information
Bycob authored and beniz committed Jun 10, 2022
1 parent c52fce6 commit 30b2143
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions server/joligan_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import json
import subprocess
import os
import shutil

import torch.multiprocessing as mp

Expand Down Expand Up @@ -164,3 +165,17 @@ async def delete_train(name: str):
return {"message": "ok", "name": name}
else:
raise HTTPException(status_code=404, detail="Not found")


@app.delete(
"/fs/",
status_code=200,
summary="Delete a file or a directory in the filesystem",
description="This endpoint can be dangerous, use it with extreme caution",
)
async def delete_path(path: str):
if os.path.isdir(path):
shutil.rmtree(path)
else:
os.remove(path)
return {"message": "ok"}

0 comments on commit 30b2143

Please sign in to comment.