Update api_logic.py
Browse files- api_logic.py +35 -58
api_logic.py
CHANGED
@@ -4,13 +4,13 @@ import os
|
|
4 |
|
5 |
api_variable = os.getenv('api_key')
|
6 |
|
7 |
-
#
|
8 |
-
globs.ph_set = 0
|
9 |
-
globs.ph_on_set = 0
|
10 |
-
globs.ec_set = 0
|
11 |
-
globs.ec_A_set = 0
|
12 |
-
globs.ec_B_set = 0
|
13 |
-
globs.ec_C_set = 0
|
14 |
globs.l_ON_h_set = 0
|
15 |
globs.l_ON_m_set = 0
|
16 |
globs.l_OFF_h_set = 0
|
@@ -22,61 +22,38 @@ def api():
|
|
22 |
err = 0
|
23 |
|
24 |
if api_variable == request.args.get('api'):
|
25 |
-
globs.
|
26 |
-
globs.
|
27 |
-
globs.
|
28 |
-
globs.
|
29 |
-
globs.
|
30 |
-
globs.
|
31 |
-
globs.
|
32 |
-
globs.
|
33 |
-
globs.
|
34 |
-
globs.
|
35 |
-
|
36 |
-
globs.
|
37 |
-
globs.rLi = request.args.get('rLi')
|
38 |
-
globs.rWat = request.args.get('rWat')
|
39 |
-
globs.rRas = request.args.get('rRas')
|
40 |
-
globs.rPH = request.args.get('rPH')
|
41 |
-
globs.rEC = request.args.get('rEC')
|
42 |
-
globs.rSl = request.args.get('rSl')
|
43 |
-
globs.rLe = request.args.get('rLe')
|
44 |
-
globs.alW = request.args.get('alW')
|
45 |
|
46 |
-
globs.ph_eep = request.args.get('ph_eep')
|
47 |
-
globs.ph_on_eep = request.args.get('ph_on_eep')
|
48 |
-
globs.ec_eep = request.args.get('ec_eep')
|
49 |
-
globs.ec_A_eep = request.args.get('ec_A_eep')
|
50 |
-
globs.ec_B_eep = request.args.get('ec_B_eep')
|
51 |
-
globs.ec_C_eep = request.args.get('ec_C_eep')
|
52 |
-
|
53 |
-
globs.l_ON_h_eep = request.args.get('l_ON_h_eep')
|
54 |
-
globs.l_ON_m_eep = request.args.get('l_ON_m_eep')
|
55 |
-
globs.l_OFF_h_eep = request.args.get('l_OFF_h_eep')
|
56 |
-
globs.l_OFF_m_eep = request.args.get('l_OFF_m_eep')
|
57 |
-
globs.t_Voz_eep = request.args.get('t_Voz_eep')
|
58 |
-
|
59 |
err = 1
|
60 |
else:
|
61 |
err = 0
|
62 |
-
|
63 |
-
#
|
64 |
response = {
|
65 |
-
"
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
"err": int(err)
|
79 |
-
}
|
80 |
}
|
81 |
|
82 |
-
return jsonify(response)
|
|
|
4 |
|
5 |
api_variable = os.getenv('api_key')
|
6 |
|
7 |
+
# Устанавливаем значения по умолчанию
|
8 |
+
globs.ph_set = 0.0
|
9 |
+
globs.ph_on_set = 0.0
|
10 |
+
globs.ec_set = 0.0
|
11 |
+
globs.ec_A_set = 0.0
|
12 |
+
globs.ec_B_set = 0.0
|
13 |
+
globs.ec_C_set = 0.0
|
14 |
globs.l_ON_h_set = 0
|
15 |
globs.l_ON_m_set = 0
|
16 |
globs.l_OFF_h_set = 0
|
|
|
22 |
err = 0
|
23 |
|
24 |
if api_variable == request.args.get('api'):
|
25 |
+
globs.ph_set = float(request.args.get('ph_set', 0.0))
|
26 |
+
globs.ph_on_set = float(request.args.get('ph_on_set', 0.0))
|
27 |
+
globs.ec_set = float(request.args.get('ec_set', 0.0))
|
28 |
+
globs.ec_A_set = float(request.args.get('ec_A_set', 0.0))
|
29 |
+
globs.ec_B_set = float(request.args.get('ec_B_set', 0.0))
|
30 |
+
globs.ec_C_set = float(request.args.get('ec_C_set', 0.0))
|
31 |
+
globs.l_ON_h_set = int(request.args.get('l_ON_h_set', 0))
|
32 |
+
globs.l_ON_m_set = int(request.args.get('l_ON_m_set', 0))
|
33 |
+
globs.l_OFF_h_set = int(request.args.get('l_OFF_h_set', 0))
|
34 |
+
globs.l_OFF_m_set = int(request.args.get('l_OFF_m_set', 0))
|
35 |
+
globs.ec_t_Voz_set = int(request.args.get('ec_t_Voz_set', 0))
|
36 |
+
globs.eep_set = int(request.args.get('eep_set', 0))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
err = 1
|
39 |
else:
|
40 |
err = 0
|
41 |
+
|
42 |
+
# Формируем ответ в нужном формате
|
43 |
response = {
|
44 |
+
"OFF_h_set": int(globs.l_OFF_h_set),
|
45 |
+
"OFF_m_set": int(globs.l_OFF_m_set),
|
46 |
+
"ON_h_set": int(globs.l_ON_h_set),
|
47 |
+
"ON_m_set": int(globs.l_ON_m_set),
|
48 |
+
"ec_A_set": float(globs.ec_A_set),
|
49 |
+
"ec_B_set": float(globs.ec_B_set),
|
50 |
+
"ec_C_set": float(globs.ec_C_set),
|
51 |
+
"ec_set": float(globs.ec_set),
|
52 |
+
"ec_t_Voz_set": int(globs.ec_t_Voz_set),
|
53 |
+
"eep_set": int(globs.eep_set),
|
54 |
+
"err": int(err),
|
55 |
+
"ph_on_set": float(globs.ph_on_set),
|
56 |
+
"ph_set": float(globs.ph_set)
|
|
|
|
|
57 |
}
|
58 |
|
59 |
+
return jsonify(response)
|