Spaces:
Sleeping
Sleeping
import flask | |
from flask import request, jsonify, send_file | |
import os | |
from dotenv import load_dotenv | |
import globs | |
from flask import render_template | |
from api_logic import api | |
import my_sqlite | |
load_dotenv() | |
# Выполнение кода для создания базы данных и таблицы | |
my_sqlite.create_database_and_table() | |
globs.eep_set = 0 | |
globs.ph_set = "5.55" | |
globs.ph_on_set = "2.5" | |
globs.ec_set = "1.00" | |
globs.ec_A_set = "2.5" | |
globs.ec_B_set = "2.5" | |
globs.ec_C_set = "2.5" | |
globs.l_ON_h_set = "10" | |
globs.l_ON_m_set = "30" | |
globs.l_OFF_h_set = "22" | |
globs.l_OFF_m_set = "30" | |
globs.ec_t_Voz_set = "27" | |
app = flask.Flask(__name__, template_folder="./") | |
app.config['DEBUG'] = True | |
def index(): | |
return flask.render_template('index.html') | |
def online(): | |
return render_template('online.html') | |
def online_api(): | |
return jsonify(dey=globs.dey, | |
wek=globs.wek, | |
v_hid=globs.v_hid, | |
v_min=globs.v_min, | |
ph=globs.ph, | |
ec=globs.ec, | |
tS=globs.tS, | |
tA=globs.tA, | |
hDm=globs.hDm, | |
sVen=globs.sVen, | |
rFul=globs.rFul, | |
rLi=globs.rLi, | |
rWat=globs.rWat, | |
rRas=globs.rRas, | |
rPH=globs.rPH, | |
rEC=globs.rEC, | |
rSl=globs.rSl, | |
rLe=globs.rLe, | |
alW=globs.alW | |
) | |
def settings(): | |
return render_template('settings.html') | |
def settings_api(): | |
return jsonify(ph_eep=globs.ph_eep, | |
ph_on_eep=globs.ph_on_eep, | |
ec_eep=globs.ec_eep, | |
ec_A_eep=globs.ec_A_eep, | |
ec_B_eep=globs.ec_B_eep, | |
ec_C_eep=globs.ec_C_eep, | |
l_ON_h_eep=globs.l_ON_h_eep, | |
l_ON_m_eep=globs.l_ON_m_eep, | |
l_OFF_h_eep=globs.l_OFF_h_eep, | |
l_OFF_m_eep=globs.l_OFF_m_eep, | |
t_Voz_eep=globs.t_Voz_eep | |
) | |
def set_res(): | |
globs.eep_set = 0 | |
return jsonify(value_set="reset") | |
def set_pH_value(): | |
ph_value = request.args.get('value') | |
globs.ph_set = ph_value | |
globs.eep_set = 1 | |
return "pH value set successfully" | |
def ph_on_value(): | |
ph_on_value = request.args.get('value') | |
globs.ph_on_set = ph_on_value | |
globs.eep_set = 2 | |
return "EC value set successfully" | |
def set_EC_value(): | |
ec_value = request.args.get('value') | |
globs.ec_set = ec_value | |
globs.eep_set = 3 | |
return "EC value set successfully" | |
def ec_A_setValue(): | |
ec_A_setValue = request.args.get('value') | |
globs.ec_A_set = ec_A_setValue | |
globs.eep_set = 4 | |
return "EC value set successfully" | |
def ec_B_setValue(): | |
ec_B_setValue = request.args.get('value') | |
globs.ec_B_set = ec_B_setValue | |
globs.eep_set = 5 | |
return "EC value set successfully" | |
def ec_C_setValue(): | |
ec_C_setValue = request.args.get('value') | |
globs.ec_C_set = ec_C_setValue | |
globs.eep_set = 6 | |
return "EC value set successfully" | |
def l_ON_set(): | |
globs.l_ON_h_set = request.args.get('l_ON_h_set') | |
globs.l_ON_m_set = request.args.get('l_ON_m_set') | |
globs.eep_set = 7 | |
return "EC value set successfully" | |
def l_OFF_set(): | |
globs.l_OFF_h_set = request.args.get('l_OFF_h_set') | |
globs.l_OFF_m_set = request.args.get('l_OFF_m_set') | |
globs.eep_set = 8 | |
return "EC value set successfully" | |
def t_Voz_eep_set(): | |
t_Voz_eep_set = request.args.get('value') | |
globs.ec_t_Voz_set = t_Voz_eep_set | |
globs.eep_set = 9 | |
return "EC value set successfully" | |
def handle_api(): | |
response = api() | |
return response | |
def handle_sql_save(): | |
response = sql_save() | |
return response | |
def graf_json(): | |
return render_template('graf.html') | |
if __name__ == '__main__': | |
app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860))) |