|
from flask import request, jsonify |
|
import globs |
|
import os |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
api_variabl = os.getenv('api_key') |
|
|
|
|
|
def save_db(): |
|
err = 0 |
|
|
|
|
|
if api_variabl == request.args.get('api'): |
|
|
|
dey_db = request.args.get('dey') |
|
wek_db = request.args.get('wek') |
|
v_hid_db = request.args.get('v_hid') |
|
v_min_db = request.args.get('v_min') |
|
ph_db = request.args.get('ph') |
|
ec_db = request.args.get('ec') |
|
tS_db = request.args.get('tS') |
|
tA_db = request.args.get('tA') |
|
hDm_db = request.args.get('hDm') |
|
sVen_db = request.args.get('sVen') |
|
|
|
ec_A_eep_db = request.args.get('ec_A_eep') |
|
ec_B_eep_db = request.args.get('ec_B_eep') |
|
ec_C_eep_db = request.args.get('ec_C_eep') |
|
|
|
|
|
data = { |
|
'dey': dey_db, |
|
'wek': wek_db, |
|
'v_hid': v_hid_db, |
|
'v_min': v_min_db, |
|
'ph': ph_db, |
|
'ec': ec_db, |
|
'tS': tS_db, |
|
'tA': tA_db, |
|
'hDm': hDm_db, |
|
'sVen': sVen_db, |
|
'ec_A_eep': ec_A_eep_db, |
|
'ec_B_eep': ec_B_eep_db, |
|
'ec_C_eep': ec_C_eep_db |
|
} |
|
|
|
|
|
response = requests.post('http://your_api_url.com/save_data', json=data) |
|
|
|
|
|
if response.status_code == 200: |
|
err = 1 |
|
else: |
|
err = 0 |
|
else: |
|
err = 0 |
|
|
|
|
|
response_data = { |
|
"1_ph_set": globs.ph_set, |
|
"2_ph_on_set": globs.ph_on_set, |
|
"3_ec_set": globs.ec_set, |
|
"4_ec_A_set": globs.ec_A_set, |
|
"5_ec_B_set": globs.ec_B_set, |
|
"6_ec_C_set": globs.ec_C_set, |
|
"7_l_ON_h_set": globs.l_ON_h_set, |
|
"7_l_ON_m_set": globs.l_ON_m_set, |
|
"8_l_OFF_h_set": globs.l_OFF_h_set, |
|
"8_l_OFF_m_set": globs.l_OFF_m_set, |
|
"9_ec_t_Voz_set": globs.ec_t_Voz_set, |
|
"eep_set": globs.eep_set, |
|
"err": err |
|
} |
|
|
|
|
|
return jsonify(response_data) |