yifan0sun commited on
Commit
a2120da
·
1 Parent(s): 0397def

Update server.py

Browse files
Files changed (1) hide show
  1. server.py +13 -0
server.py CHANGED
@@ -156,6 +156,19 @@ def data_check():
156
 
157
 
158
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
 
160
 
161
 
 
156
 
157
 
158
 
159
+ @app.get("/list_data")
160
+ def list_data():
161
+ base_path = Path("/data")
162
+ all_items = []
163
+
164
+ for path in base_path.rglob("*"): # recursive glob
165
+ all_items.append({
166
+ "path": str(path.relative_to(base_path)),
167
+ "type": "dir" if path.is_dir() else "file",
168
+ "size": path.stat().st_size if path.is_file() else None
169
+ })
170
+
171
+ return {"items": all_items}
172
 
173
 
174