From 41938a5c470e2daaadcee38cb346900f715b0e23 Mon Sep 17 00:00:00 2001 From: Kendrick Bollens Date: Fri, 30 Jan 2026 00:17:49 +0100 Subject: [PATCH] fixed most of the issues i could find with to little sleep --- cleaning_logs.db | Bin 0 -> 12288 bytes dashboard.py | 323 +++++++++++++++++++++++++++++++++++++++++++++++ flake.lock | 27 ++++ test.py | 35 ++--- 4 files changed, 370 insertions(+), 15 deletions(-) create mode 100644 cleaning_logs.db create mode 100644 dashboard.py create mode 100644 flake.lock diff --git a/cleaning_logs.db b/cleaning_logs.db new file mode 100644 index 0000000000000000000000000000000000000000..99a8d6cc974312684246a5fb89438ef0ab75e523 GIT binary patch literal 12288 zcmeI&%SyvQ6b9g#HdPQbf(s$5S+?}Tq-ndz$|!>rdo!kBSD}|t3QbDe)V=NnAH)ao zAzZri4O}^?bkSIFqYL3b + + + Room Cleaning Dashboard + + + +

đŸ§¹ Room Cleaning Status

+ +
+ +
+ + {% for building_name, floors in buildings.items() %} +
+

{{ building_name }}

+ {% for floor in floors %} +
+
Etage {{ loop.index }}
+
+ {% for room in floor %} + {% set room_str = room|string %} + {% set status = statuses.get(room_str, {"is_today": False, "last_cleaned": None}) %} +
+ {{ room }} + + {% if status.last_cleaned %} + {{ status.last_cleaned[5:10] }}
{{ status.last_cleaned[11:16] }} + {% else %}Never{% endif %} +
+
+ {% endfor %} +
+
+ {% endfor %} +
+ {% endfor %} + + {% if special_rooms %} +
+

Sonderräume

+
+
+ {% for room in special_rooms %} + {% set status = statuses.get(room, {"is_today": False, "last_cleaned": None}) %} +
+ {{ room }} + + {% if status.last_cleaned %} + {{ status.last_cleaned[5:10] }}
{{ status.last_cleaned[11:16] }} + {% else %}Never{% endif %} +
+
+ {% endfor %} +
+
+
+ {% endif %} + + + + +''' + +if __name__ == '__main__': + app.run(host='0.0.0.0', port=5001, debug=True) diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..6f6bfa6 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1769461804, + "narHash": "sha256-msG8SU5WsBUfVVa/9RPLaymvi5bI8edTavbIq3vRlhI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "bfc1b8a4574108ceef22f02bafcf6611380c100d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/test.py b/test.py index 7f5d4ea..eee6bce 100644 --- a/test.py +++ b/test.py @@ -3,37 +3,42 @@ from flask import Flask, request from datetime import datetime app = Flask(__name__) -DB_FILE = "logs.db" +DB_FILE = "cleaning_logs.db" def init_db(): with sqlite3.connect(DB_FILE) as conn: conn.execute(''' - CREATE TABLE IF NOT EXISTS post_logs ( + CREATE TABLE IF NOT EXISTS cleaning_events ( id INTEGER PRIMARY KEY AUTOINCREMENT, - timestamp TEXT, - content_type TEXT, - body TEXT + room_number TEXT, + cleaned_at TEXT ) ''') @app.route('/', methods=['POST']) def handle_post(): - content_type = request.headers.get('Content-Type') - body = request.get_data(as_text=True) - timestamp = datetime.now().isoformat() + # Extract the room number from the POST body + # .strip('"') removes extra quotes if the sender includes them + room_number = request.get_data(as_text=True).strip().strip('"') + + if not room_number: + return "Missing room number", 400 - # Log to Console - print(f"[{timestamp}] Logging POST: {body[:50]}...") + timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S") - # Log to SQLite + # Log to Console for your visibility + print(f"Room {room_number} marked as cleaned at {timestamp}") + + # Save to SQLite with sqlite3.connect(DB_FILE) as conn: conn.execute( - "INSERT INTO post_logs (timestamp, content_type, body) VALUES (?, ?, ?)", - (timestamp, content_type, body) + "INSERT INTO cleaning_events (room_number, cleaned_at) VALUES (?, ?)", + (room_number, timestamp) ) - return "Logged successfully", 200 + return f"Room {room_number} logged.", 200 if __name__ == '__main__': init_db() - app.run(host='0.0.0.0', port=5000, debug=True) + # Binding to 0.0.0.0 so devices on your network can reach it + app.run(host='0.0.0.0', port=5000)