Exemple #1
0
    def getData():
        from_date = request.args.get('from_date')
        to_date = request.args.get('to_date')

        sleep(FAKE_WAIT_TIME)
        if from_date is None or to_date is None:
            return jsonify(findByTimestamp(DATA, 60))
        else:
            return jsonify(findBetweenDates(DATA, from_date, to_date))
Exemple #2
0
    @cross_origin()
    def getData():
        from_date = request.args.get('from_date')
        to_date = request.args.get('to_date')

        sleep(FAKE_WAIT_TIME)
        if from_date is None or to_date is None:
            return jsonify(findByTimestamp(DATA, 60))
        else:
            return jsonify(findBetweenDates(DATA, from_date, to_date))

    app.run(port=app_settings["rest_port"])

elif app_settings['type'] == "mqtt":
    client = mqtt.Client(app_settings['broker_name'])
    client.connect("127.0.0.1")
    client.loop_start()

    while True:
        prepared_json = findByTimestamp(DATA, 60)
        prepared_json["app_name"] = app_settings['broker_name']
        client.publish(f"ib/sysintrz/lista2/{app_settings['broker_name']}",
                       json.dumps(prepared_json))
        print(f'[{app_settings["broker_name"]}]SEND')
        sleep(int(app_settings['broker_time']))

    client.loop_stop()

else:
    print("Wrong config data")