Spaces:
Sleeping
Sleeping
DmitrMakeev
commited on
Commit
•
c134c84
1
Parent(s):
5e72b86
Update google_db.py
Browse files- google_db.py +30 -23
google_db.py
CHANGED
@@ -18,8 +18,7 @@ def save_db():
|
|
18 |
|
19 |
# Проверяем условие и выполняем кусок кода, если условие истинно
|
20 |
if api_variabl == request.args.get('api'):
|
21 |
-
#
|
22 |
-
|
23 |
dey_db = request.args.get('dey')
|
24 |
wek_db = request.args.get('wek')
|
25 |
v_hid_db = request.args.get('v_hid')
|
@@ -31,25 +30,40 @@ def save_db():
|
|
31 |
hDm_db = request.args.get('hDm')
|
32 |
sVen_db = request.args.get('sVen')
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
ec_A_eep_db = request.args.get('ec_A_eep')
|
38 |
ec_B_eep_db = request.args.get('ec_B_eep')
|
39 |
ec_C_eep_db = request.args.get('ec_C_eep')
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
else:
|
46 |
-
# Вставьте сюда ваш кусок кода, который должен выполняться, если условие ложно
|
47 |
-
|
48 |
err = 0
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
response = {
|
53 |
"1_ph_set": globs.ph_set,
|
54 |
"2_ph_on_set": globs.ph_on_set,
|
55 |
"3_ec_set": globs.ec_set,
|
@@ -66,11 +80,4 @@ def save_db():
|
|
66 |
}
|
67 |
|
68 |
# Возвращаем JSON-объект
|
69 |
-
return jsonify(
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
|
|
18 |
|
19 |
# Проверяем условие и выполняем кусок кода, если условие истинно
|
20 |
if api_variabl == request.args.get('api'):
|
21 |
+
# Получаем данные из request.args
|
|
|
22 |
dey_db = request.args.get('dey')
|
23 |
wek_db = request.args.get('wek')
|
24 |
v_hid_db = request.args.get('v_hid')
|
|
|
30 |
hDm_db = request.args.get('hDm')
|
31 |
sVen_db = request.args.get('sVen')
|
32 |
|
|
|
|
|
|
|
33 |
ec_A_eep_db = request.args.get('ec_A_eep')
|
34 |
ec_B_eep_db = request.args.get('ec_B_eep')
|
35 |
ec_C_eep_db = request.args.get('ec_C_eep')
|
36 |
|
37 |
+
# Формируем данные для POST запроса
|
38 |
+
data = {
|
39 |
+
'dey': dey_db,
|
40 |
+
'wek': wek_db,
|
41 |
+
'v_hid': v_hid_db,
|
42 |
+
'v_min': v_min_db,
|
43 |
+
'ph': ph_db,
|
44 |
+
'ec': ec_db,
|
45 |
+
'tS': tS_db,
|
46 |
+
'tA': tA_db,
|
47 |
+
'hDm': hDm_db,
|
48 |
+
'sVen': sVen_db,
|
49 |
+
'ec_A_eep': ec_A_eep_db,
|
50 |
+
'ec_B_eep': ec_B_eep_db,
|
51 |
+
'ec_C_eep': ec_C_eep_db
|
52 |
+
}
|
53 |
+
|
54 |
+
# Отправляем POST запрос
|
55 |
+
response = requests.post('http://your_api_url.com/save_data', json=data)
|
56 |
+
|
57 |
+
# Проверяем статус ответа
|
58 |
+
if response.status_code == 200:
|
59 |
+
err = 1
|
60 |
+
else:
|
61 |
+
err = 0
|
62 |
else:
|
|
|
|
|
63 |
err = 0
|
64 |
+
|
65 |
+
# Создаем JSON-объект для возвращения
|
66 |
+
response_data = {
|
|
|
67 |
"1_ph_set": globs.ph_set,
|
68 |
"2_ph_on_set": globs.ph_on_set,
|
69 |
"3_ec_set": globs.ec_set,
|
|
|
80 |
}
|
81 |
|
82 |
# Возвращаем JSON-объект
|
83 |
+
return jsonify(response_data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|