config = {
"port": 8081,
"host": "localhost",
+ "prefix": "h"
}
return config
def load_webhooks(path):
- webhooks = [
- {
- "path": "/example/",
+ webhooks = {
+ "example": {
+ "name": "Example hook",
+ "description": "Example Hook that demonstrates everything",
"unit": "example.service"
}
- ]
+ }
return webhooks
--- /dev/null
+from flask import Flask
+from config import util
+
+config = util.read_runtime_config("./config")
+webhooks = util.load_webhooks("/etc/systemd/webhook")
+
+
+app = Flask(__name__)
+
+
+@app.route(f"/{config['prefix']}/<path:hook>")
+def activate_hook(hook):
+ assert hook in webhooks
+ webhook = webhooks.get(hook)
+ app.logger.warning(f"[GET]: {webhook['description']} ")
+ return ""