Spaces:
Runtime error
Runtime error
tweaks
Browse files
main.py
CHANGED
|
@@ -28,29 +28,37 @@ def files_in_folder(path: str):
|
|
| 28 |
folder = ROOT / path
|
| 29 |
path_glob = folder.glob("*")
|
| 30 |
res = pd.DataFrame(
|
| 31 |
-
[("..", "", "", True)]
|
| 32 |
-
+
|
| 33 |
[
|
| 34 |
(
|
| 35 |
f.name,
|
| 36 |
f.stat().st_size,
|
| 37 |
pd.Timestamp(int(f.stat().st_mtime), unit="s"),
|
| 38 |
-
f.
|
| 39 |
)
|
| 40 |
for f in path_glob
|
| 41 |
],
|
| 42 |
columns=["path", "size", "mtime", "folder"],
|
| 43 |
-
).sort_values(["folder"], ascending=False)
|
| 44 |
|
| 45 |
res["path"] = res.apply(
|
| 46 |
lambda x: f"<a href=/files/{path}{x.path}{'/' if x.folder else ''}>{x.path}</a>",
|
| 47 |
axis=1,
|
| 48 |
)
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
table = to_html_datatable(
|
| 51 |
df=res.drop(columns="folder"),
|
| 52 |
-
classes="display compact",
|
| 53 |
showIndex=False,
|
|
|
|
| 54 |
)
|
| 55 |
|
| 56 |
return f"""
|
|
|
|
| 28 |
folder = ROOT / path
|
| 29 |
path_glob = folder.glob("*")
|
| 30 |
res = pd.DataFrame(
|
|
|
|
|
|
|
| 31 |
[
|
| 32 |
(
|
| 33 |
f.name,
|
| 34 |
f.stat().st_size,
|
| 35 |
pd.Timestamp(int(f.stat().st_mtime), unit="s"),
|
| 36 |
+
f.is_dir(),
|
| 37 |
)
|
| 38 |
for f in path_glob
|
| 39 |
],
|
| 40 |
columns=["path", "size", "mtime", "folder"],
|
| 41 |
+
).sort_values(["folder", "path"], ascending=[False, True])
|
| 42 |
|
| 43 |
res["path"] = res.apply(
|
| 44 |
lambda x: f"<a href=/files/{path}{x.path}{'/' if x.folder else ''}>{x.path}</a>",
|
| 45 |
axis=1,
|
| 46 |
)
|
| 47 |
|
| 48 |
+
res.loc[-1] = [
|
| 49 |
+
(
|
| 50 |
+
f"<a href=/files/{path.parent}/>..</a>",
|
| 51 |
+
"",
|
| 52 |
+
"",
|
| 53 |
+
True,
|
| 54 |
+
)
|
| 55 |
+
]
|
| 56 |
+
|
| 57 |
table = to_html_datatable(
|
| 58 |
df=res.drop(columns="folder"),
|
| 59 |
+
classes="display nowrap compact",
|
| 60 |
showIndex=False,
|
| 61 |
+
paging=False
|
| 62 |
)
|
| 63 |
|
| 64 |
return f"""
|