added stuff + monitoring (to logfile)

This commit is contained in:
Rens Pastoor
2025-10-28 15:00:32 +01:00
parent aa32f81e97
commit 3dda7d01a0
8 changed files with 407 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
from flask import Flask, request, jsonify
from datetime import datetime
import json
app = Flask(__name__)
@app.route('/collect', methods=['POST'])
def collect():
data = request.get_json()
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
with open("collected_data.log", "a") as f:
f.write(f"{timestamp} - {json.dumps(data)}\n")
print(f"[{timestamp}] Data received from {data.get('hostname', 'unknown')}")
return jsonify({"status": "success"}), 200
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)