Spaces:
Runtime error
Runtime error
Upload 2 files
Browse files- app.py +13 -3
- templates/index.html +10 -3
app.py
CHANGED
|
@@ -1198,10 +1198,19 @@ def create_account_and_send_whatsapp():
|
|
| 1198 |
last_name = data.get('lastName')
|
| 1199 |
phone = data.get('phone')
|
| 1200 |
email = data.get('email')
|
| 1201 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1202 |
|
| 1203 |
logger.info(f"Received data: firstName={first_name}, lastName={last_name}, email={email}, phone={phone}")
|
| 1204 |
-
logger.info(f"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1205 |
|
| 1206 |
# Validate email format
|
| 1207 |
if not email or '@' not in email:
|
|
@@ -1314,7 +1323,8 @@ def create_account_and_send_whatsapp():
|
|
| 1314 |
return jsonify({
|
| 1315 |
"success": success,
|
| 1316 |
"message": overall_message,
|
| 1317 |
-
"details": messages
|
|
|
|
| 1318 |
})
|
| 1319 |
|
| 1320 |
except requests.exceptions.HTTPError as e:
|
|
|
|
| 1198 |
last_name = data.get('lastName')
|
| 1199 |
phone = data.get('phone')
|
| 1200 |
email = data.get('email')
|
| 1201 |
+
|
| 1202 |
+
# Extract search criteria to generate recommendations
|
| 1203 |
+
user_input = data.get('description', '')
|
| 1204 |
+
price_range = data.get('price_range', None)
|
| 1205 |
+
property_type = data.get('property_type', None)
|
| 1206 |
|
| 1207 |
logger.info(f"Received data: firstName={first_name}, lastName={last_name}, email={email}, phone={phone}")
|
| 1208 |
+
logger.info(f"Search criteria: description='{user_input}', price_range={price_range}, property_type={property_type}")
|
| 1209 |
+
|
| 1210 |
+
# Generate recommendations directly in backend
|
| 1211 |
+
logger.info("Generating recommendations in backend...")
|
| 1212 |
+
recommendations = get_recommendations(user_input, price_range, property_type)
|
| 1213 |
+
logger.info(f"Generated {len(recommendations)} recommendations")
|
| 1214 |
|
| 1215 |
# Validate email format
|
| 1216 |
if not email or '@' not in email:
|
|
|
|
| 1323 |
return jsonify({
|
| 1324 |
"success": success,
|
| 1325 |
"message": overall_message,
|
| 1326 |
+
"details": messages,
|
| 1327 |
+
"recommendations": recommendations # Return generated recommendations
|
| 1328 |
})
|
| 1329 |
|
| 1330 |
except requests.exceptions.HTTPError as e:
|
templates/index.html
CHANGED
|
@@ -849,7 +849,7 @@
|
|
| 849 |
return;
|
| 850 |
}
|
| 851 |
|
| 852 |
-
// Send account details and
|
| 853 |
const accountResponse = await fetch('/create_account_and_send_whatsapp', {
|
| 854 |
method: 'POST',
|
| 855 |
headers: {
|
|
@@ -861,7 +861,9 @@
|
|
| 861 |
email,
|
| 862 |
phone,
|
| 863 |
password,
|
| 864 |
-
|
|
|
|
|
|
|
| 865 |
})
|
| 866 |
});
|
| 867 |
|
|
@@ -887,7 +889,12 @@
|
|
| 887 |
successMessage += result.message || 'Recommendations sent!';
|
| 888 |
}
|
| 889 |
alert(successMessage);
|
| 890 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 891 |
} else {
|
| 892 |
// Show detailed error information
|
| 893 |
let errorMessage = 'Failed to create account: ' + (result.error || result.message);
|
|
|
|
| 849 |
return;
|
| 850 |
}
|
| 851 |
|
| 852 |
+
// Send account details and search criteria to the backend
|
| 853 |
const accountResponse = await fetch('/create_account_and_send_whatsapp', {
|
| 854 |
method: 'POST',
|
| 855 |
headers: {
|
|
|
|
| 861 |
email,
|
| 862 |
phone,
|
| 863 |
password,
|
| 864 |
+
description: formData.description,
|
| 865 |
+
price_range: formData.price_range,
|
| 866 |
+
property_type: formData.property_type
|
| 867 |
})
|
| 868 |
});
|
| 869 |
|
|
|
|
| 889 |
successMessage += result.message || 'Recommendations sent!';
|
| 890 |
}
|
| 891 |
alert(successMessage);
|
| 892 |
+
// Display the recommendations that were generated by the backend
|
| 893 |
+
if (result.recommendations) {
|
| 894 |
+
displayRecommendations(result.recommendations);
|
| 895 |
+
} else {
|
| 896 |
+
displayRecommendations(recommendations);
|
| 897 |
+
}
|
| 898 |
} else {
|
| 899 |
// Show detailed error information
|
| 900 |
let errorMessage = 'Failed to create account: ' + (result.error || result.message);
|