Spaces:
Runtime error
Runtime error
Update routes/recommend.py
Browse files- routes/recommend.py +8 -1
routes/recommend.py
CHANGED
|
@@ -62,6 +62,10 @@ def recommend_tv():
|
|
| 62 |
}), 500
|
| 63 |
result = response.json()
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
# Handle different response formats (like book route)
|
| 66 |
if isinstance(result, list):
|
| 67 |
# Microservice returns a direct list
|
|
@@ -69,7 +73,10 @@ def recommend_tv():
|
|
| 69 |
else:
|
| 70 |
# Microservice returns structured response with status
|
| 71 |
if result.get("status") != "success":
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
| 73 |
raw_items = result.get(RESPONSE_KEYS.get(rec_type, "items"), [])
|
| 74 |
|
| 75 |
# Normalize response format
|
|
|
|
| 62 |
}), 500
|
| 63 |
result = response.json()
|
| 64 |
|
| 65 |
+
# Debug: Print what we received
|
| 66 |
+
print(f"TV microservice response: {result}")
|
| 67 |
+
print(f"Response type: {type(result)}")
|
| 68 |
+
|
| 69 |
# Handle different response formats (like book route)
|
| 70 |
if isinstance(result, list):
|
| 71 |
# Microservice returns a direct list
|
|
|
|
| 73 |
else:
|
| 74 |
# Microservice returns structured response with status
|
| 75 |
if result.get("status") != "success":
|
| 76 |
+
error_msg = result.get("message") or result.get("error") or "Unknown error"
|
| 77 |
+
print(f"TV microservice error: {error_msg}")
|
| 78 |
+
print(f"Full error response: {result}")
|
| 79 |
+
return jsonify({"error": error_msg, "full_response": result}), 500
|
| 80 |
raw_items = result.get(RESPONSE_KEYS.get(rec_type, "items"), [])
|
| 81 |
|
| 82 |
# Normalize response format
|