|
import sqlite3 |
|
|
|
|
|
from flask import request, jsonify |
|
import globs |
|
import os |
|
|
|
|
|
|
|
|
|
def create_database_and_table(): |
|
|
|
conn = sqlite3.connect('mydatabase.db') |
|
cur = conn.cursor() |
|
|
|
|
|
cur.execute(''' |
|
CREATE TABLE IF NOT EXISTS my_table ( |
|
id INTEGER PRIMARY KEY AUTOINCREMENT, |
|
column1 TEXT, |
|
column2 TEXT, |
|
column3 TEXT, |
|
column4 TEXT, |
|
column5 TEXT, |
|
column6 TEXT, |
|
column7 TEXT, |
|
column8 TEXT, |
|
column9 TEXT, |
|
column10 TEXT |
|
) |
|
''') |
|
|
|
|
|
conn.commit() |
|
cur.close() |
|
conn.close() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
api_variabl = os.getenv('api_key_s') |
|
|
|
|
|
def sql_save(): |
|
err = 0 |
|
|
|
|
|
if api_variabl == request.args.get('api'): |
|
|
|
|
|
globs.dey = request.args.get('dey') |
|
globs.wek = request.args.get('wek') |
|
globs.v_hid = request.args.get('v_hid') |
|
globs.v_min = request.args.get('v_min') |
|
globs.ph = request.args.get('ph') |
|
globs.ec = request.args.get('ec') |
|
globs.tS = request.args.get('tS') |
|
globs.tA = request.args.get('tA') |
|
globs.hDm = request.args.get('hDm') |
|
globs.sVen = request.args.get('sVen') |
|
|
|
globs.rFul = request.args.get('rFul') |
|
globs.rLi = request.args.get('rLi') |
|
globs.rWat = request.args.get('rWat') |
|
globs.rRas = request.args.get('rRas') |
|
globs.rPH = request.args.get('rPH') |
|
globs.rEC = request.args.get('rEC') |
|
globs.rSl = request.args.get('rSl') |
|
globs.rLe = request.args.get('rLe') |
|
globs.alW = request.args.get('alW') |
|
|
|
globs.ph_eep = request.args.get('ph_eep') |
|
globs.ph_on_eep = request.args.get('ph_on_eep') |
|
globs.ec_eep = request.args.get('ec_eep') |
|
globs.ec_A_eep = request.args.get('ec_A_eep') |
|
globs.ec_B_eep = request.args.get('ec_B_eep') |
|
globs.ec_C_eep = request.args.get('ec_C_eep') |
|
|
|
globs.l_ON_h_eep = request.args.get('l_ON_h_eep') |
|
globs.l_ON_m_eep = request.args.get('l_ON_m_eep') |
|
globs.l_OFF_h_eep = request.args.get('l_OFF_h_eep') |
|
globs.l_OFF_m_eep = request.args.get('l_OFF_m_eep') |
|
globs.t_Voz_eep = request.args.get('t_Voz_eep') |
|
|
|
err = 1 |
|
pass |
|
else: |
|
|
|
|
|
err = 0 |
|
pass |
|
|
|
|
|
response = { |
|
"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) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|