Spaces:
Sleeping
Sleeping
DmitrMakeev
commited on
Update google_db.py
Browse files- google_db.py +13 -4
google_db.py
CHANGED
@@ -4,6 +4,7 @@ import os
|
|
4 |
import asyncio
|
5 |
import aiohttp
|
6 |
|
|
|
7 |
|
8 |
|
9 |
api_variabl = os.getenv('api_key')
|
@@ -18,7 +19,7 @@ async def async_save_db(data):
|
|
18 |
else:
|
19 |
return False
|
20 |
|
21 |
-
def save_db(
|
22 |
err = 0
|
23 |
|
24 |
if api_variabl == request.args.get('api'):
|
@@ -39,12 +40,20 @@ def save_db(app):
|
|
39 |
|
40 |
data = f"action=addData&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}"
|
41 |
|
42 |
-
#
|
43 |
-
asyncio.
|
|
|
|
|
|
|
44 |
|
45 |
response_data = {
|
46 |
"eep_set": globs.eep_set,
|
47 |
"err": err
|
48 |
}
|
49 |
|
50 |
-
return jsonify(response_data)
|
|
|
|
|
|
|
|
|
|
|
|
4 |
import asyncio
|
5 |
import aiohttp
|
6 |
|
7 |
+
from threading import Thread
|
8 |
|
9 |
|
10 |
api_variabl = os.getenv('api_key')
|
|
|
19 |
else:
|
20 |
return False
|
21 |
|
22 |
+
def save_db():
|
23 |
err = 0
|
24 |
|
25 |
if api_variabl == request.args.get('api'):
|
|
|
40 |
|
41 |
data = f"action=addData&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}"
|
42 |
|
43 |
+
# Запускаем асинхронный запрос в отдельном потоке
|
44 |
+
loop = asyncio.new_event_loop()
|
45 |
+
asyncio.set_event_loop(loop)
|
46 |
+
loop.run_until_complete(async_save_db(data))
|
47 |
+
loop.close()
|
48 |
|
49 |
response_data = {
|
50 |
"eep_set": globs.eep_set,
|
51 |
"err": err
|
52 |
}
|
53 |
|
54 |
+
return jsonify(response_data)
|
55 |
+
|
56 |
+
@app.route("/save_db", methods=['GET'])
|
57 |
+
def handle_save_db():
|
58 |
+
response = save_db()
|
59 |
+
return response
|