cleanup and bug fixed

upload saved the key of the dict as int not str
This commit is contained in:
Anika 2024-03-20 13:28:19 +01:00
parent 4314f97ee3
commit 8d91c63a12
2 changed files with 7 additions and 18 deletions

3
app.py
View File

@ -128,8 +128,7 @@ def upload():
content = alarm["message"]
global alarmIndex
alarmIndex += 1
activeAlarms[alarmIndex] = {'datetime':datetime.strftime(time,"%d.%m.%Y %H:%M"),'message':content}
activeAlarms[str(alarmIndex)] = {'datetime':datetime.strftime(time,"%d.%m.%Y %H:%M"),'message':content}
# ja, wir schreiben einfach das ganze File neu, ist aber einfacher
with open('alarms.json', 'w') as f:
json.dump(activeAlarms, f, indent=2)

View File

@ -67,28 +67,17 @@
method: "POST",
body: body,
});
fetch("/processAlarm", {
method: "GET"
}).then(response => {
return response.text();
})
.then(html => {
upcomingAlarms.innerHTML = html
})
fetch("/processpAlarm", {
method: "GET"
}).then(response => {
return response.text();
})
.then(html => {
previousAlarms.innerHTML = html
})
reloadAlarms();
}
async function deleteAlarm(id){
const response = await fetch("http://127.0.0.1:5000/deletealarm", {
method: "POST",
body: id,
});
reloadAlarms();
}
function reloadAlarms(){
fetch("/processAlarm", {
method: "GET"
}).then(response => {
@ -105,6 +94,7 @@
.then(html => {
previousAlarms.innerHTML = html
})
}
function checkAlarms(){