Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -981,13 +981,31 @@ if __name__ == "__main__":
|
|
981 |
|
982 |
@app.route('/calculation', methods=['POST'])
|
983 |
def handle_calculation():
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
991 |
|
992 |
|
993 |
|
|
|
981 |
|
982 |
@app.route('/calculation', methods=['POST'])
|
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'],
|
994 |
+
'Mg': data['profileSettings']['Mg'],
|
995 |
+
'Ca': data['profileSettings']['Ca'],
|
996 |
+
'S': data['profileSettings']['S'],
|
997 |
+
'N (NO3-)': data['profileSettings']['N (NO3-)'],
|
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 |
|