DmitrMakeev commited on
Commit
787a192
·
verified ·
1 Parent(s): c877030

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -10
app.py CHANGED
@@ -1100,24 +1100,33 @@ def handle_calculation():
1100
  try:
1101
  data = request.json
1102
 
1103
- # Создаем ВЕБ-версию калькулятора
1104
- web_calculator = WebNutrientCalculator(volume_liters=data['profileSettings']['liters'])
1105
 
1106
  # Выполняем расчет
1107
- result = web_calculator.web_calculate(
1108
  profile_settings=data['profileSettings'],
1109
  fertilizer_constants=data['fertilizerConstants']
1110
  )
1111
 
1112
- return jsonify(result)
 
 
 
 
 
 
 
 
 
1113
 
1114
  except Exception as e:
1115
- return jsonify({
1116
- "error": str(e),
1117
- "message": "Ошибка расчета"
1118
- }), 500
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