示例#1
0
def data_now():
    data = Temperature.get_temperature()
    idNode = str(request.query_string).split("=")
    node = idNode[1].replace("'", "")

    obj = {
        "id_node": idNode[1],
        "sensors": [
            {
                "type": "temperature",
                "value": float(data[0])
            },
            {
                "type": "humidity",
                "value": float(data[1])
            }
        ],
    }

    dado = json.dumps(obj)
    return jsonify(dado)
示例#2
0
def send_temperature():
    data = Temperature.get_temperature()
    idNode = str(request.query_string).split("=")
    node = idNode[1].replace("'", "")

    obj = {
        "id_node": idNode[1],
        "sensors": [
            {
                "type": "temperature",
                "value": float(data[0])
            },
            {
                "type": "humidity",
                "value": float(data[1])
            }
        ],
    }

    dado = json.dumps(obj)
    response = requests.post(
        "https://prediction-service-api.herokuapp.com/data", headers={"content-type": "application/json"}, data=dado)

    return jsonify(dado)