Skip to content

Simple Event collectorΒΆ

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

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) = '',debug=True)

gunicorn is required for launching the application, install it using following command: 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