Flussonic Watcher documentation


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.route('/events',methods = ['POST'])
def events():
    d = request.get_json(force=True)

    with open("/tmp/events.txt", "a") as write_events:

    return jsonify(d)

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

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

Run command, for example:

gunicorn --bind 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