Spaces:
Sleeping
Sleeping
DmitrMakeev
commited on
Commit
•
2923221
1
Parent(s):
c4c9fac
Update app.py
Browse files
app.py
CHANGED
@@ -1,31 +1,49 @@
|
|
1 |
import flask
|
2 |
-
from flask import request, jsonify,
|
3 |
import os
|
|
|
|
|
|
|
4 |
from dotenv import load_dotenv
|
5 |
import globs
|
|
|
6 |
from api_logic import api
|
7 |
-
from google_sheets import send_data_to_google_sheets, start_scheduler
|
8 |
|
9 |
-
|
|
|
10 |
load_dotenv()
|
11 |
|
12 |
app = flask.Flask(__name__, template_folder="./")
|
13 |
app.config['DEBUG'] = True
|
14 |
|
|
|
|
|
|
|
|
|
15 |
@app.route("/")
|
16 |
def index():
|
17 |
-
return render_template('index.html')
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
@app.route('/online', methods=['GET'])
|
20 |
def online():
|
21 |
return render_template('online.html')
|
22 |
|
|
|
|
|
|
|
|
|
|
|
23 |
@app.route('/online_api', methods=['GET'])
|
24 |
def online_api():
|
25 |
return jsonify(dey=globs.dey,
|
26 |
wek=globs.wek,
|
27 |
-
|
28 |
-
|
29 |
ph=globs.ph,
|
30 |
ec=globs.ec,
|
31 |
tS=globs.tS,
|
@@ -43,10 +61,15 @@ def online_api():
|
|
43 |
alW=globs.alW
|
44 |
)
|
45 |
|
|
|
|
|
|
|
|
|
46 |
@app.route('/settings', methods=['GET'])
|
47 |
def settings():
|
48 |
return render_template('settings.html')
|
49 |
|
|
|
50 |
@app.route('/settings_api', methods=['GET'])
|
51 |
def settings_api():
|
52 |
return jsonify(ph_eep=globs.ph_eep,
|
@@ -62,11 +85,21 @@ def settings_api():
|
|
62 |
t_Voz_eep=globs.t_Voz_eep
|
63 |
)
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
@app.route('/set_res')
|
66 |
def set_res():
|
67 |
globs.eep_set = 0
|
68 |
return jsonify(value_set="reset")
|
69 |
|
|
|
|
|
|
|
70 |
@app.route('/pH_set')
|
71 |
def set_pH_value():
|
72 |
ph_value = request.args.get('value')
|
@@ -74,6 +107,7 @@ def set_pH_value():
|
|
74 |
globs.eep_set = 1
|
75 |
return "pH value set successfully"
|
76 |
|
|
|
77 |
@app.route('/ph_on_set')
|
78 |
def ph_on_value():
|
79 |
ph_on_value = request.args.get('value')
|
@@ -81,6 +115,8 @@ def ph_on_value():
|
|
81 |
globs.eep_set = 2
|
82 |
return "EC value set successfully"
|
83 |
|
|
|
|
|
84 |
@app.route('/EC_set')
|
85 |
def set_EC_value():
|
86 |
ec_value = request.args.get('value')
|
@@ -109,6 +145,7 @@ def ec_C_setValue():
|
|
109 |
globs.eep_set = 6
|
110 |
return "EC value set successfully"
|
111 |
|
|
|
112 |
@app.route('/l_ON_set')
|
113 |
def l_ON_set():
|
114 |
globs.l_ON_h_set = request.args.get('l_ON_h_set')
|
@@ -116,6 +153,8 @@ def l_ON_set():
|
|
116 |
globs.eep_set = 7
|
117 |
return "EC value set successfully"
|
118 |
|
|
|
|
|
119 |
@app.route('/l_OFF_set')
|
120 |
def l_OFF_set():
|
121 |
globs.l_OFF_h_set = request.args.get('l_OFF_h_set')
|
@@ -123,6 +162,9 @@ def l_OFF_set():
|
|
123 |
globs.eep_set = 8
|
124 |
return "EC value set successfully"
|
125 |
|
|
|
|
|
|
|
126 |
@app.route('/t_Voz_eep_set')
|
127 |
def t_Voz_eep_set():
|
128 |
t_Voz_eep_set = request.args.get('value')
|
@@ -130,21 +172,30 @@ def t_Voz_eep_set():
|
|
130 |
globs.eep_set = 9
|
131 |
return "EC value set successfully"
|
132 |
|
|
|
|
|
133 |
@app.route("/api", methods=['GET'])
|
134 |
def handle_api():
|
135 |
response = api()
|
136 |
return response
|
137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
@app.route('/graf_json', methods=['GET'])
|
139 |
def graf_json():
|
140 |
return render_template('graf.html')
|
141 |
|
|
|
|
|
|
|
|
|
142 |
if __name__ == '__main__':
|
143 |
-
|
144 |
-
scheduler = start_scheduler() # Запуск планировщика
|
145 |
-
try:
|
146 |
-
app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860)), use_reloader=False)
|
147 |
-
except KeyboardInterrupt:
|
148 |
-
print("Завершение работы сервера.")
|
149 |
-
finally:
|
150 |
-
scheduler.shutdown()
|
|
|
1 |
import flask
|
2 |
+
from flask import request, jsonify, send_file
|
3 |
import os
|
4 |
+
|
5 |
+
|
6 |
+
|
7 |
from dotenv import load_dotenv
|
8 |
import globs
|
9 |
+
from flask import render_template
|
10 |
from api_logic import api
|
|
|
11 |
|
12 |
+
|
13 |
+
|
14 |
load_dotenv()
|
15 |
|
16 |
app = flask.Flask(__name__, template_folder="./")
|
17 |
app.config['DEBUG'] = True
|
18 |
|
19 |
+
|
20 |
+
|
21 |
+
|
22 |
+
|
23 |
@app.route("/")
|
24 |
def index():
|
25 |
+
return flask.render_template('index.html')
|
26 |
+
|
27 |
+
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
|
32 |
@app.route('/online', methods=['GET'])
|
33 |
def online():
|
34 |
return render_template('online.html')
|
35 |
|
36 |
+
|
37 |
+
|
38 |
+
|
39 |
+
|
40 |
+
|
41 |
@app.route('/online_api', methods=['GET'])
|
42 |
def online_api():
|
43 |
return jsonify(dey=globs.dey,
|
44 |
wek=globs.wek,
|
45 |
+
v_hid=globs.v_hid,
|
46 |
+
v_min=globs.v_min,
|
47 |
ph=globs.ph,
|
48 |
ec=globs.ec,
|
49 |
tS=globs.tS,
|
|
|
61 |
alW=globs.alW
|
62 |
)
|
63 |
|
64 |
+
|
65 |
+
|
66 |
+
|
67 |
+
|
68 |
@app.route('/settings', methods=['GET'])
|
69 |
def settings():
|
70 |
return render_template('settings.html')
|
71 |
|
72 |
+
|
73 |
@app.route('/settings_api', methods=['GET'])
|
74 |
def settings_api():
|
75 |
return jsonify(ph_eep=globs.ph_eep,
|
|
|
85 |
t_Voz_eep=globs.t_Voz_eep
|
86 |
)
|
87 |
|
88 |
+
|
89 |
+
|
90 |
+
|
91 |
+
|
92 |
+
|
93 |
+
|
94 |
+
|
95 |
@app.route('/set_res')
|
96 |
def set_res():
|
97 |
globs.eep_set = 0
|
98 |
return jsonify(value_set="reset")
|
99 |
|
100 |
+
|
101 |
+
|
102 |
+
|
103 |
@app.route('/pH_set')
|
104 |
def set_pH_value():
|
105 |
ph_value = request.args.get('value')
|
|
|
107 |
globs.eep_set = 1
|
108 |
return "pH value set successfully"
|
109 |
|
110 |
+
|
111 |
@app.route('/ph_on_set')
|
112 |
def ph_on_value():
|
113 |
ph_on_value = request.args.get('value')
|
|
|
115 |
globs.eep_set = 2
|
116 |
return "EC value set successfully"
|
117 |
|
118 |
+
|
119 |
+
|
120 |
@app.route('/EC_set')
|
121 |
def set_EC_value():
|
122 |
ec_value = request.args.get('value')
|
|
|
145 |
globs.eep_set = 6
|
146 |
return "EC value set successfully"
|
147 |
|
148 |
+
|
149 |
@app.route('/l_ON_set')
|
150 |
def l_ON_set():
|
151 |
globs.l_ON_h_set = request.args.get('l_ON_h_set')
|
|
|
153 |
globs.eep_set = 7
|
154 |
return "EC value set successfully"
|
155 |
|
156 |
+
|
157 |
+
|
158 |
@app.route('/l_OFF_set')
|
159 |
def l_OFF_set():
|
160 |
globs.l_OFF_h_set = request.args.get('l_OFF_h_set')
|
|
|
162 |
globs.eep_set = 8
|
163 |
return "EC value set successfully"
|
164 |
|
165 |
+
|
166 |
+
|
167 |
+
|
168 |
@app.route('/t_Voz_eep_set')
|
169 |
def t_Voz_eep_set():
|
170 |
t_Voz_eep_set = request.args.get('value')
|
|
|
172 |
globs.eep_set = 9
|
173 |
return "EC value set successfully"
|
174 |
|
175 |
+
|
176 |
+
|
177 |
@app.route("/api", methods=['GET'])
|
178 |
def handle_api():
|
179 |
response = api()
|
180 |
return response
|
181 |
|
182 |
+
|
183 |
+
|
184 |
+
|
185 |
+
|
186 |
+
|
187 |
+
|
188 |
+
|
189 |
+
|
190 |
+
|
191 |
+
|
192 |
@app.route('/graf_json', methods=['GET'])
|
193 |
def graf_json():
|
194 |
return render_template('graf.html')
|
195 |
|
196 |
+
|
197 |
+
|
198 |
+
|
199 |
+
|
200 |
if __name__ == '__main__':
|
201 |
+
app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|