adaugat lab4 si lab5

Signed-off-by: hellisabove <robertnedela15@gmail.com>
This commit is contained in:
hellisabove
2026-05-25 11:13:40 +03:00
parent 8b7c9a5527
commit 35893a4012
78 changed files with 60025 additions and 0 deletions
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
+12
View File
@@ -0,0 +1,12 @@
""" Data model for user accounts """
ACCOUNTS = {
"admin@example.com": "h4ckm3",
}
def check_login(email, password):
""" Checks whether the specified credentials are valid """
if ACCOUNTS.get(email) == password:
return True
return False
+36
View File
@@ -0,0 +1,36 @@
"""
Data model for IoT sensors.
"""
import os, json
iot_data = {
"ext_temp": 0,
"int_temp": 0,
"ext_hum": 0,
"int_hum": 0,
"rain": 0
}
DATA_FILE = "/home/nedi/iap1-labs/lab4/iot_data.json"
def load_data(path):
if os.path.exists(path):
with open(path, "r") as f:
stored = json.load(f)
for key in set(iot_data.keys()):
if key in stored:
iot_data[key] = stored[key]
load_data("/home/nedi/iap1-labs/lab4/iot_data.json")
def save_data(path):
with open(path, "w") as f:
json.dump(iot_data, f, indent=2)
def fetch_iot_data():
return iot_data
def set_iot_data(data):
# TODO: update the dictionary with the new data
iot_data.update(data)
pass