Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -22,6 +22,24 @@ def health_check():
|
|
22 |
|
23 |
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
|
27 |
from datetime import datetime
|
|
|
22 |
|
23 |
|
24 |
|
25 |
+
REPO_ID = "rahul7star/ohamlab"
|
26 |
+
BASE_URL = f"https://huggingface.co/{REPO_ID}/resolve/main/demo/"
|
27 |
+
|
28 |
+
@app.get("/images")
|
29 |
+
def list_images():
|
30 |
+
try:
|
31 |
+
all_files = list_repo_files(REPO_ID)
|
32 |
+
demo_files = [f for f in all_files if f.startswith("demo/")]
|
33 |
+
|
34 |
+
image_files = [
|
35 |
+
BASE_URL + f[len("demo/"):]
|
36 |
+
for f in demo_files
|
37 |
+
if f.lower().endswith((".png", ".jpg", ".jpeg", ".webp"))
|
38 |
+
]
|
39 |
+
|
40 |
+
return {"images": image_files}
|
41 |
+
except Exception as e:
|
42 |
+
return {"error": str(e)}
|
43 |
|
44 |
|
45 |
from datetime import datetime
|