Spaces:
Paused
Paused
Download python/api/delete_work_dir_file.py from OnyxMunk/GravityFalls: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/spaces/OnyxMunk/GravityFalls/resolve/main/python/api/delete_work_dir_file.py
- Command line
-
hf download hf://spaces/OnyxMunk/GravityFalls/python/api/delete_work_dir_file.py
-
curl -L -o delete_work_dir_file.py https://huggingface.co/spaces/OnyxMunk/GravityFalls/resolve/main/python/api/delete_work_dir_file.py
1.06 kB
| from python.helpers.api import ApiHandler, Input, Output, Request, Response | |
| from python.helpers.file_browser import FileBrowser | |
| from python.helpers import files, runtime | |
| from python.api import get_work_dir_files | |
| class DeleteWorkDirFile(ApiHandler): | |
| async def process(self, input: Input, request: Request) -> Output: | |
| file_path = input.get("path", "") | |
| if not file_path.startswith("/"): | |
| file_path = f"/{file_path}" | |
| current_path = input.get("currentPath", "") | |
| # browser = FileBrowser() | |
| res = await runtime.call_development_function(delete_file, file_path) | |
| if res: | |
| # Get updated file list | |
| # result = browser.get_files(current_path) | |
| result = await runtime.call_development_function(get_work_dir_files.get_files, current_path) | |
| return {"data": result} | |
| else: | |
| raise Exception("File not found or could not be deleted") | |
| async def delete_file(file_path: str): | |
| browser = FileBrowser() | |
| return browser.delete_file(file_path) | |