File size: 2,436 Bytes
f18f04b
3b33a44
e9edc80
 
5e5ef88
edba818
c7511da
e9edc80
ec447d0
e9edc80
3ab3bfe
ec447d0
 
 
 
1bfefb1
30cb684
7a42f0c
70f7ff7
ec447d0
 
 
 
1bfefb1
 
71e318b
 
336718b
2ab4f80
 
 
ec447d0
 
1bfefb1
2a9b787
247757c
2a3d5b7
 
ab83c54
 
2a3d5b7
 
 
 
 
9102404
 
 
 
 
 
 
 
 
 
2a3d5b7
09441e0
c7511da
 
 
 
856645f
 
 
1bfefb1
856645f
 
 
e40f660
ff195d4
5e334b8
 
 
dd91eb9
 
 
 
 
 
856645f
 
 
 
 
1321c2f
 
 
 
 
 
856645f
a1a3ecc
12a6081
 
a1a3ecc
 
 
856645f
 
1a7f16a
c7511da
 
 
 
 
 
 
 
 
 
f18f04b
0cf3e5e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import flask
from flask import request, jsonify
import os
from dotenv import load_dotenv
import globs
from flask import render_template
from api_logic import api
load_dotenv()

app = flask.Flask(__name__, template_folder="./")
app.config['DEBUG'] = True





@app.route("/")
def index():
    return flask.render_template('index.html')






@app.route('/online', methods=['GET'])
def online():
    return render_template('online.html')






@app.route('/online_api', methods=['GET'])
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
                  )





@app.route('/settings', methods=['GET'])
def settings():
    return render_template('settings.html')


@app.route('/settings_api', methods=['GET'])
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
                  )




@app.route('/pH_set')
def set_pH_value():
    ph_value = request.args.get('value')
    globs.ph_set = ph_value
    globs.eep_set = 1
    return "pH value set successfully"

@app.route('/EC_set')
def set_EC_value():
    ec_value = request.args.get('value')
    globs.ec_set = ec_value
    globs.eep_set = 2
    return "EC value set successfully"

    
@app.route("/api", methods=['GET'])
def handle_api():
    response = api()
    return response







if __name__ == '__main__':
    app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860)))