diff --git a/.gitignore b/.gitignore
index be40c27..a380544 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1 @@
-/webserver/plots/
+/webserver/static/plots/
diff --git a/webserver/data_big.json b/webserver/data_big.json
new file mode 100644
index 0000000..52e39ec
--- /dev/null
+++ b/webserver/data_big.json
@@ -0,0 +1,100 @@
+{
+ "location": "Building B - Research Wing",
+ "sensors": [
+ {
+ "id": "temp-A12",
+ "type": "temperature",
+ "unit": "°C",
+ "readings": [
+ { "ts": 1747814400, "value": 21.0 },
+ { "ts": 1747818000, "value": 21.4 },
+ { "ts": 1747821600, "value": 22.1 },
+ { "ts": 1747825200, "value": 22.6 },
+ { "ts": 1747828800, "value": 22.8 },
+ { "ts": 1747832400, "value": 23.0 }
+ ]
+ },
+ {
+ "id": "hum_B2",
+ "type": "humidity",
+ "unit": "%",
+ "readings": [
+ { "ts": 1747814400, "value": 50.1 },
+ { "ts": 1747818000, "value": 51.7 },
+ { "ts": 1747821600, "value": 49.3 },
+ { "ts": 1747825200, "value": 48.8 },
+ { "ts": 1747828800, "value": 47.6 },
+ { "ts": 1747832400, "value": 46.9 },
+ { "ts": 1747836000, "value": 45.2 },
+ { "ts": 1747839600, "value": 44.7 },
+ { "ts": 1747843200, "value": 43.5 }
+ ]
+ },
+ {
+ "id": "PRES-009",
+ "type": "pressure",
+ "unit": "hPa",
+ "readings": [
+ { "ts": 1747814400, "value": 1011.0 },
+ { "ts": 1747818000, "value": 1010.8 }
+ ]
+ },
+ {
+ "id": "sensorX04",
+ "type": "CO2",
+ "unit": "ppm",
+ "readings": [
+ { "ts": 1747814400, "value": 415 },
+ { "ts": 1747818000, "value": 420 },
+ { "ts": 1747821600, "value": 432 },
+ { "ts": 1747825200, "value": 440 },
+ { "ts": 1747828800, "value": 437 }
+ ]
+ },
+ {
+ "id": "luxSensor-1",
+ "type": "light",
+ "unit": "lux",
+ "readings": [
+ { "ts": 1747814400, "value": 300 },
+ { "ts": 1747818000, "value": 450 },
+ { "ts": 1747821600, "value": 600 },
+ { "ts": 1747825200, "value": 550 },
+ { "ts": 1747828800, "value": 500 },
+ { "ts": 1747832400, "value": 480 },
+ { "ts": 1747836000, "value": 470 },
+ { "ts": 1747839600, "value": 460 },
+ { "ts": 1747843200, "value": 455 },
+ { "ts": 1747846800, "value": 440 },
+ { "ts": 1747850400, "value": 430 },
+ { "ts": 1747854000, "value": 420 }
+ ]
+ },
+ {
+ "id": "vib_07",
+ "type": "vibration",
+ "unit": "mm/s",
+ "readings": [
+ { "ts": 1747814400, "value": 0.05 },
+ { "ts": 1747818000, "value": 0.06 },
+ { "ts": 1747821600, "value": 0.08 },
+ { "ts": 1747825200, "value": 0.07 },
+ { "ts": 1747828800, "value": 0.09 },
+ { "ts": 1747832400, "value": 0.1 },
+ { "ts": 1747836000, "value": 0.12 }
+ ]
+ },
+ {
+ "id": "motion-Z3",
+ "type": "motion",
+ "unit": "count",
+ "readings": [
+ { "ts": 1747814400, "value": 3 },
+ { "ts": 1747818000, "value": 1 },
+ { "ts": 1747821600, "value": 0 },
+ { "ts": 1747825200, "value": 2 }
+ ]
+ }
+ ]
+}
+
diff --git a/webserver/data.json b/webserver/data_smol.json
similarity index 99%
rename from webserver/data.json
rename to webserver/data_smol.json
index af037db..6a570b0 100644
--- a/webserver/data.json
+++ b/webserver/data_smol.json
@@ -1,3 +1,4 @@
+
{
"location": "Building A - Lab 3",
"sensors": [
diff --git a/webserver/server.py b/webserver/server.py
index d6235fe..1de45f9 100644
--- a/webserver/server.py
+++ b/webserver/server.py
@@ -1,28 +1,39 @@
+# Copyright 2025 Kieler, Chiara
+#
+# Licensed under the AGPLv3.0 (the "License");
+# You may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.gnu.org/licenses/
+
+
from datetime import datetime
-import re
-from flask import Flask, send_from_directory, render_template
+from flask import Flask, render_template
import json
+import matplotlib
+matplotlib.use('Agg')
import matplotlib.pyplot as plt
# Global Variables:
-jsonpath = "data.json"
-htmldata = ""
+jsonpath = "data_big.json"
+sensors: dict = {}
-# class Entries:
-# def __init__(self, id: str, ts: list, value: list):
-# self.id = id
-# templist: list = []
-# for i in range(len(ts)):
-# templist.append([ts[i], value[i]])
-# self.entries: list = templist
-#
-# def printEntries(self):
-# print(self.entries)
-#
-#
-# tese = Entries("sensor0", [1, 2, 3, 4], [10, 20, 30, 40])
-# tese.printEntries()
+def readJson():
+ f = open(jsonpath)
+ jsondata = json.load(f) # returns JSON object as a dictionary
+ for i in jsondata["sensors"]: # Iterating through the json list
+ timestamps: list = []
+ values: list = []
+ # print(len(i["readings"]))
+ for j in range(len(i["readings"])):
+ timestamps.append(i["readings"][j]["ts"])
+ values.append(i["readings"][j]["value"])
+ # print(i)
+ # print(i["readings"][1])
+ # print("\n")
+ sensors[i["id"]] = Sensor(i["id"], i["unit"], i["type"], timestamps, values)
+ f.close()
class Sensor:
@@ -97,113 +108,13 @@ class Sensor:
plt.close()
return path
- # def formatLine(self, ts: int):
- # for i in self.ts:
- # if i == ts:
- # return f"{self.timedate}> {self.values[]}"
+readJson()
-# Json
-f = open(jsonpath)
-jsondata = json.load(f) # returns JSON object as a dictionary
-# sensordict = dict()
-sensors: dict = {}
-for i in jsondata["sensors"]: # Iterating through the json list
- timestamps: list = []
- values: list = []
- # print(len(i["readings"]))
- for j in range(len(i["readings"])):
- timestamps.append(i["readings"][j]["ts"])
- values.append(i["readings"][j]["value"])
- # print(i)
- # print(i["readings"][1])
- # print("\n")
- # sensordict[i["id"]] = [i["type"], i["unit"], i["readings"]]
- # print(sensordict[i["id"]])
- sensors[i["id"]] = Sensor(i["id"], i["unit"], i["type"], timestamps, values)
+# print("\n")
+# print(sensors)
-f.close()
-print("\n")
-# print(sensordict)
-print(sensors)
-# print(sensors["sensor_001"].getReadings(limit=2, reversed=True, timetype="time"))
-
-# for i in sensordict:
-# type = sensordict[i][0]
-# unit = sensordict[i][1]
-# readings = ""
-# datapoints: list = []
-# sensorrange = len(sensordict[i][2]) if len(sensordict[i][2]) < 5 else 5
-# for j in range(sensorrange):
-# datapoints.append([])
-# ts = sensordict[i][2][j]["ts"]
-# value = sensordict[i][2][j]["value"]
-# datapoints[j].append(ts)
-# datapoints[j].append(value)
-# datapoints[j].append(unit)
-# datapoints.sort(reverse=True)
-#
-# graphdata: list = [[], []]
-# for j in datapoints:
-# ts = j[0]
-# time = datetime.fromtimestamp(ts).strftime("%d.%m.%Y %H:%M.%S")
-# timeNoDate = datetime.fromtimestamp(ts).strftime("%H:%M.%S")
-# value = j[1]
-# unit = j[2]
-# # print(f"{time} {j}")
-# readings += f"{time}> {value}{unit}
"
-# graphdata[0].append(timeNoDate)
-# graphdata[1].append(value)
-#
-# # create_plot(i, unit, graphdata[0], graphdata[1])
-#
-# htmldata += f"""
-#
Id: {i}
-#Type: {type}
-#Readings:
-#