DmitrMakeev commited on
Commit
478a710
·
verified ·
1 Parent(s): 3231b49

Update api_logic.py

Browse files
Files changed (1) hide show
  1. 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.dey = request.args.get('dey')
26
- globs.wek = request.args.get('wek')
27
- globs.v_hid = request.args.get('v_hid')
28
- globs.v_min = request.args.get('v_min')
29
- globs.ph = request.args.get('ph')
30
- globs.ec = request.args.get('ec')
31
- globs.tS = request.args.get('tS')
32
- globs.tA = request.args.get('tA')
33
- globs.hDm = request.args.get('hDm')
34
- globs.sVen = request.args.get('sVen')
35
-
36
- globs.rFul = request.args.get('rFul')
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
- # Оборачиваем ответ в "set_deta"
64
  response = {
65
- "set_deta": {
66
- "ph_set": float(globs.ph_set),
67
- "ph_on_set": float(globs.ph_on_set),
68
- "ec_set": float(globs.ec_set),
69
- "ec_A_set": float(globs.ec_A_set),
70
- "ec_B_set": float(globs.ec_B_set),
71
- "ec_C_set": float(globs.ec_C_set),
72
- "ON_h_set": int(globs.l_ON_h_set),
73
- "ON_m_set": int(globs.l_ON_m_set),
74
- "OFF_h_set": int(globs.l_OFF_h_set),
75
- "OFF_m_set": int(globs.l_OFF_m_set),
76
- "ec_t_Voz_set": int(globs.ec_t_Voz_set),
77
- "eep_set": int(globs.eep_set),
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)