Flussonic Watcher documentation

Contents

Simple Event collector

The application accepts the POST-request, writes the json-data in a file /tmp/event.txt and sends it back to the sender.

from flask import Flask, request, jsonify
import json

app=Flask(__name__)

@app.route('/events',methods = ['POST'])
def events():
    d = request.get_json(force=True)

    with open("/tmp/events.txt", "a") as write_events:
        write_events.write(str(d)+'\n')

    return jsonify(d)

app.run(host = '0.0.0.0',debug=true)

For run need use gunicorn, it need to install pip3 install gunicorn.

Run command, for example:

gunicorn --bind 0.0.0.0:5000 wsgi:app -D -w 3 --log-syslog --reload -g www-data -u www-data --log-file /var/log/event_coll.log --error-logfile /var/log/event_coll_error.log