Spaces:
Sleeping
Sleeping
Commit
·
b56d2fb
1
Parent(s):
e75450b
Update
Browse files- backend/app.py +13 -10
backend/app.py
CHANGED
|
@@ -808,16 +808,19 @@ async def generate_report(
|
|
| 808 |
report_html = os.path.join(report_dir, "report.html")
|
| 809 |
json_url = f"/outputs/reports/{report_id}/report.json"
|
| 810 |
html_url = f"/outputs/reports/{report_id}/report.html"
|
| 811 |
-
|
| 812 |
-
|
| 813 |
-
#
|
| 814 |
-
|
| 815 |
-
|
| 816 |
-
|
| 817 |
-
|
| 818 |
-
|
| 819 |
-
|
| 820 |
-
|
|
|
|
|
|
|
|
|
|
| 821 |
|
| 822 |
download_pdf_btn = f'<a href="{pdf_url}" download style="text-decoration:none"><button class="btn-secondary">Download PDF</button></a>' if pdf_url else ''
|
| 823 |
|
|
|
|
| 808 |
report_html = os.path.join(report_dir, "report.html")
|
| 809 |
json_url = f"/outputs/reports/{report_id}/report.json"
|
| 810 |
html_url = f"/outputs/reports/{report_id}/report.html"
|
| 811 |
+
|
| 812 |
+
# Prefer annotated image URL from the analysis summary (ai_summary) if present,
|
| 813 |
+
# otherwise fall back to the analysis annotated_image_url (which may be the analysis_id).
|
| 814 |
+
annotated_img = ai_summary.get('annotated_image_url') or report_data.get("analysis", {}).get("annotated_image_url") or ""
|
| 815 |
+
|
| 816 |
+
# Normalize annotated image path: allow absolute http(s) URLs or ensure relative paths start with '/'.
|
| 817 |
+
annotated_img_full = ""
|
| 818 |
+
if annotated_img:
|
| 819 |
+
if isinstance(annotated_img, str) and annotated_img.startswith(('http://', 'https://')):
|
| 820 |
+
annotated_img_full = annotated_img
|
| 821 |
+
else:
|
| 822 |
+
# ensure leading slash for relative paths so StaticFiles routing works
|
| 823 |
+
annotated_img_full = annotated_img if str(annotated_img).startswith('/') else '/' + str(annotated_img)
|
| 824 |
|
| 825 |
download_pdf_btn = f'<a href="{pdf_url}" download style="text-decoration:none"><button class="btn-secondary">Download PDF</button></a>' if pdf_url else ''
|
| 826 |
|