Spaces:
Paused
Paused
Download python/api/get_work_dir_files.py from OnyxMunk/GravityFalls: direct link, hf CLI and curl.
- Browser
- Download file 903 Bytes
-
https://huggingface.co/spaces/OnyxMunk/GravityFalls/resolve/main/python/api/get_work_dir_files.py
- Command line
-
hf download hf://spaces/OnyxMunk/GravityFalls/python/api/get_work_dir_files.py
-
curl -L -o get_work_dir_files.py https://huggingface.co/spaces/OnyxMunk/GravityFalls/resolve/main/python/api/get_work_dir_files.py
903 Bytes
| from python.helpers.api import ApiHandler, Request, Response | |
| from python.helpers.file_browser import FileBrowser | |
| from python.helpers import runtime, files | |
| class GetWorkDirFiles(ApiHandler): | |
| def get_methods(cls): | |
| return ["GET"] | |
| async def process(self, input: dict, request: Request) -> dict | Response: | |
| current_path = request.args.get("path", "") | |
| if current_path == "$WORK_DIR": | |
| # if runtime.is_development(): | |
| # current_path = "work_dir" | |
| # else: | |
| # current_path = "root" | |
| current_path = "/a0" | |
| # browser = FileBrowser() | |
| # result = browser.get_files(current_path) | |
| result = await runtime.call_development_function(get_files, current_path) | |
| return {"data": result} | |
| async def get_files(path): | |
| browser = FileBrowser() | |
| return browser.get_files(path) | |