Try to fix logo
Browse files- backend/runner/app.py +12 -6
backend/runner/app.py
CHANGED
|
@@ -164,14 +164,20 @@ def serve_js(filename):
|
|
| 164 |
print(f"Error serving JS file {filename}: {e}")
|
| 165 |
return "Internal server error", 500
|
| 166 |
|
| 167 |
-
#
|
| 168 |
-
@app.route("/images
|
| 169 |
def list_work_images(work_id: str):
|
| 170 |
"""
|
| 171 |
Return absolute URLs for all JPEG / PNG images that belong to <work_id>.
|
|
|
|
| 172 |
"""
|
| 173 |
-
|
| 174 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
if not img_dir.is_dir():
|
| 176 |
print(f"❌ Work directory not found: {img_dir}")
|
| 177 |
return jsonify([])
|
|
@@ -180,10 +186,10 @@ def list_work_images(work_id: str):
|
|
| 180 |
f for f in img_dir.iterdir() if f.suffix.lower() in (".jpg", ".jpeg", ".png")
|
| 181 |
)
|
| 182 |
host = request.host_url.rstrip("/")
|
| 183 |
-
urls = [f"{host}/marker/{
|
| 184 |
return jsonify(urls)
|
| 185 |
|
| 186 |
-
#
|
| 187 |
@app.route("/images/<path:filename>")
|
| 188 |
def serve_images(filename):
|
| 189 |
"""Serve image files."""
|
|
|
|
| 164 |
print(f"Error serving JS file {filename}: {e}")
|
| 165 |
return "Internal server error", 500
|
| 166 |
|
| 167 |
+
# Route for work_id images (only matches actual work_ids)
|
| 168 |
+
@app.route("/images/W<work_id>", methods=["GET"])
|
| 169 |
def list_work_images(work_id: str):
|
| 170 |
"""
|
| 171 |
Return absolute URLs for all JPEG / PNG images that belong to <work_id>.
|
| 172 |
+
Only matches work_ids that start with 'W' followed by numbers.
|
| 173 |
"""
|
| 174 |
+
# Validate that work_id is numeric
|
| 175 |
+
if not work_id.isdigit():
|
| 176 |
+
return "Invalid work_id format", 400
|
| 177 |
+
|
| 178 |
+
full_work_id = f"W{work_id}"
|
| 179 |
+
print(f"🔍 list_work_images called with work_id: {full_work_id}")
|
| 180 |
+
img_dir = MARKER_DIR / full_work_id
|
| 181 |
if not img_dir.is_dir():
|
| 182 |
print(f"❌ Work directory not found: {img_dir}")
|
| 183 |
return jsonify([])
|
|
|
|
| 186 |
f for f in img_dir.iterdir() if f.suffix.lower() in (".jpg", ".jpeg", ".png")
|
| 187 |
)
|
| 188 |
host = request.host_url.rstrip("/")
|
| 189 |
+
urls = [f"{host}/marker/{full_work_id}/{f.name}" for f in files]
|
| 190 |
return jsonify(urls)
|
| 191 |
|
| 192 |
+
# Route for frontend images (catches everything else)
|
| 193 |
@app.route("/images/<path:filename>")
|
| 194 |
def serve_images(filename):
|
| 195 |
"""Serve image files."""
|