DmitrMakeev commited on
Commit
ddf83cd
·
verified ·
1 Parent(s): e381455

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -22
app.py CHANGED
@@ -983,14 +983,11 @@ if __name__ == "__main__":
983
  def handle_calculation():
984
  try:
985
  data = request.json
986
- print("Получены данные:", data) # Логируем входящий запрос
987
-
988
- # Создаем калькулятор
989
- calculator = NutrientCalculator(
990
- volume_liters=data['profileSettings']['liters']
991
- )
992
 
993
- # Устанавливаем профиль
 
 
 
994
  calculator.target_profile = {
995
  'P': data['profileSettings']['P'],
996
  'K': data['profileSettings']['K'],
@@ -1001,26 +998,14 @@ def handle_calculation():
1001
  'N (NH4+)': data['profileSettings']['N (NH4+)']
1002
  }
1003
 
1004
- # Устанавливаем удобрения
1005
  calculator.fertilizers = data['fertilizerConstants']
1006
 
1007
  # Выполняем расчет
1008
- result = calculator.calculate()
1009
-
1010
- # Возвращаем результат
1011
- return jsonify({
1012
- "deficits": result.get('deficits', {}),
1013
- "ec": result.get('ec', 0),
1014
- "fertilizers": result.get('fertilizers', []),
1015
- "profile": result.get('profile', []),
1016
- "volume": data['profileSettings']['liters']
1017
- })
1018
 
1019
  except Exception as e:
1020
- return jsonify({
1021
- "error": str(e),
1022
- "message": "Ошибка расчета"
1023
- }), 500
1024
 
1025
 
1026
  if __name__ == '__main__':
 
983
  def handle_calculation():
984
  try:
985
  data = request.json
 
 
 
 
 
 
986
 
987
+ # Создаем калькулятор с базовыми настройками
988
+ calculator = NutrientCalculator(volume_liters=data['profileSettings']['liters'])
989
+
990
+ # Вручную устанавливаем профиль и удобрения
991
  calculator.target_profile = {
992
  'P': data['profileSettings']['P'],
993
  'K': data['profileSettings']['K'],
 
998
  'N (NH4+)': data['profileSettings']['N (NH4+)']
999
  }
1000
 
 
1001
  calculator.fertilizers = data['fertilizerConstants']
1002
 
1003
  # Выполняем расчет
1004
+ calculator.calculate()
1005
+ return jsonify(calculator.get_web_results())
 
 
 
 
 
 
 
 
1006
 
1007
  except Exception as e:
1008
+ return jsonify({"error": str(e)}), 500
 
 
 
1009
 
1010
 
1011
  if __name__ == '__main__':