Update app.py
Browse files
app.py
CHANGED
|
@@ -123,6 +123,41 @@ async def get_images(tour: str):
|
|
| 123 |
|
| 124 |
return data
|
| 125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
|
| 127 |
# ==================================================
|
| 128 |
# UPLOAD IMAGE
|
|
|
|
| 123 |
|
| 124 |
return data
|
| 125 |
|
| 126 |
+
@app.get("/")
|
| 127 |
+
async def root_status():
|
| 128 |
+
tours = []
|
| 129 |
+
|
| 130 |
+
for path in DATASET_DIR.glob("*.json"):
|
| 131 |
+
try:
|
| 132 |
+
with path.open("r", encoding="utf-8") as f:
|
| 133 |
+
data = json.load(f)
|
| 134 |
+
|
| 135 |
+
images = data.get("images", {})
|
| 136 |
+
|
| 137 |
+
banner = bool(images.get("banner"))
|
| 138 |
+
cover = bool(images.get("cover"))
|
| 139 |
+
carousel_count = len(images.get("carousel", []))
|
| 140 |
+
|
| 141 |
+
tours.append({
|
| 142 |
+
"tour": path.stem,
|
| 143 |
+
"banner": banner,
|
| 144 |
+
"cover": cover,
|
| 145 |
+
"carousel": carousel_count,
|
| 146 |
+
"total_images": int(banner) + int(cover) + carousel_count
|
| 147 |
+
})
|
| 148 |
+
|
| 149 |
+
except Exception as e:
|
| 150 |
+
tours.append({
|
| 151 |
+
"tour": path.stem,
|
| 152 |
+
"error": str(e)
|
| 153 |
+
})
|
| 154 |
+
|
| 155 |
+
return {
|
| 156 |
+
"status": "ok",
|
| 157 |
+
"service": "Mile Zero Tours Image API",
|
| 158 |
+
"cached_tours": len(tours),
|
| 159 |
+
"tours": sorted(tours, key=lambda t: t.get("tour", ""))
|
| 160 |
+
}
|
| 161 |
|
| 162 |
# ==================================================
|
| 163 |
# UPLOAD IMAGE
|