File size: 1,968 Bytes
89fe525
4da42d7
f93443c
3cc91b4
bcf8ccd
d5265cc
478a710
86c985f
 
 
 
 
 
4c9bda7
 
 
 
bcf8ccd
4c9bda7
3cc91b4
89fe525
4549c9e
 
 
478a710
 
 
 
 
 
 
 
 
 
 
 
b9feb9c
4549c9e
 
 
478a710
 
bcf8ccd
478a710
 
 
 
 
 
 
 
 
 
 
 
 
89fe525
4549c9e
478a710
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
from flask import request, jsonify
import globs
import os

api_variable = os.getenv('api_key')

# Устанавливаем значения по умолчанию
globs.ph_set = 0
globs.ph_on_set = 0
globs.ec_set = 0
globs.ec_A_set = 0
globs.ec_B_set = 0
globs.ec_C_set = 0
globs.l_ON_h_set = 0
globs.l_ON_m_set = 0
globs.l_OFF_h_set = 0
globs.l_OFF_m_set = 0
globs.ec_t_Voz_set = 0
globs.eep_set = 0

def api():
    err = 0

    if api_variable == request.args.get('api'):
        globs.ph_set = float(request.args.get('ph_set', 0.0))
        globs.ph_on_set = float(request.args.get('ph_on_set', 0.0))
        globs.ec_set = float(request.args.get('ec_set', 0.0))
        globs.ec_A_set = float(request.args.get('ec_A_set', 0.0))
        globs.ec_B_set = float(request.args.get('ec_B_set', 0.0))
        globs.ec_C_set = float(request.args.get('ec_C_set', 0.0))
        globs.l_ON_h_set = int(request.args.get('l_ON_h_set', 0))
        globs.l_ON_m_set = int(request.args.get('l_ON_m_set', 0))
        globs.l_OFF_h_set = int(request.args.get('l_OFF_h_set', 0))
        globs.l_OFF_m_set = int(request.args.get('l_OFF_m_set', 0))
        globs.ec_t_Voz_set = int(request.args.get('ec_t_Voz_set', 0))
        globs.eep_set = int(request.args.get('eep_set', 0))

        err = 1
    else:
        err = 0

    # Формируем ответ в нужном формате
    response = {
        "OFF_h_set": int(globs.l_OFF_h_set),
        "OFF_m_set": int(globs.l_OFF_m_set),
        "ON_h_set": int(globs.l_ON_h_set),
        "ON_m_set": int(globs.l_ON_m_set),
        "ec_A_set": float(globs.ec_A_set),
        "ec_B_set": float(globs.ec_B_set),
        "ec_C_set": float(globs.ec_C_set),
        "ec_set": float(globs.ec_set),
        "ec_t_Voz_set": int(globs.ec_t_Voz_set),
        "eep_set": int(globs.eep_set),
        "err": int(err),
        "ph_on_set": float(globs.ph_on_set),
        "ph_set": float(globs.ph_set)
    }

    return jsonify(response)