Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1100,24 +1100,33 @@ def handle_calculation():
|
|
1100 |
try:
|
1101 |
data = request.json
|
1102 |
|
1103 |
-
# Создаем
|
1104 |
-
|
1105 |
|
1106 |
# Выполняем расчет
|
1107 |
-
result =
|
1108 |
profile_settings=data['profileSettings'],
|
1109 |
fertilizer_constants=data['fertilizerConstants']
|
1110 |
)
|
1111 |
|
1112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1113 |
|
1114 |
except Exception as e:
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
|
1122 |
|
1123 |
|
|
|
1100 |
try:
|
1101 |
data = request.json
|
1102 |
|
1103 |
+
# Создаем веб-версию калькулятора
|
1104 |
+
web_calc = WebNutrientCalculator(volume_liters=data['profileSettings']['liters'])
|
1105 |
|
1106 |
# Выполняем расчет
|
1107 |
+
result = web_calc.web_calculate(
|
1108 |
profile_settings=data['profileSettings'],
|
1109 |
fertilizer_constants=data['fertilizerConstants']
|
1110 |
)
|
1111 |
|
1112 |
+
# Формируем ответ
|
1113 |
+
response_data = {
|
1114 |
+
'fertilizers': result['fertilizers'],
|
1115 |
+
'profile': result['profile'],
|
1116 |
+
'ec': result['ec'],
|
1117 |
+
'volume': result['volume'],
|
1118 |
+
'status': 'success'
|
1119 |
+
}
|
1120 |
+
|
1121 |
+
return jsonify(response_data), 200
|
1122 |
|
1123 |
except Exception as e:
|
1124 |
+
error_response = {
|
1125 |
+
'error': str(e),
|
1126 |
+
'message': 'Calculation error',
|
1127 |
+
'status': 'error'
|
1128 |
+
}
|
1129 |
+
return jsonify(error_response), 500
|
1130 |
|
1131 |
|
1132 |
|