main
py 29 lines 897 Bytes
Raw
1 from helpers.api import ApiHandler, Request, Response
2 from helpers.file_browser import FileBrowser
3 from helpers import runtime, files
4
5 class GetWorkDirFiles(ApiHandler):
6
7 @classmethod
8 def get_methods(cls):
9 return ["GET"]
10
11 async def process(self, input: dict, request: Request) -> dict | Response:
12 current_path = request.args.get("path", "") or "$WORK_DIR"
13 if current_path == "$WORK_DIR":
14 # if runtime.is_development():
15 # current_path = "work_dir"
16 # else:
17 # current_path = "root"
18 current_path = "/a0"
19
20 # browser = FileBrowser()
21 # result = browser.get_files(current_path)
22 result = await runtime.call_development_function(get_files, current_path)
23
24 return {"data": result}
25
26
27 async def get_files(path):
28 browser = FileBrowser()
29 return browser.get_files(path)