cleanup and bug fixed
upload saved the key of the dict as int not str
This commit is contained in:
parent
4314f97ee3
commit
8d91c63a12
3
app.py
3
app.py
|
@ -128,8 +128,7 @@ def upload():
|
||||||
content = alarm["message"]
|
content = alarm["message"]
|
||||||
global alarmIndex
|
global alarmIndex
|
||||||
alarmIndex += 1
|
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
|
# ja, wir schreiben einfach das ganze File neu, ist aber einfacher
|
||||||
with open('alarms.json', 'w') as f:
|
with open('alarms.json', 'w') as f:
|
||||||
json.dump(activeAlarms, f, indent=2)
|
json.dump(activeAlarms, f, indent=2)
|
||||||
|
|
|
@ -67,28 +67,17 @@
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: body,
|
body: body,
|
||||||
});
|
});
|
||||||
fetch("/processAlarm", {
|
reloadAlarms();
|
||||||
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
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
async function deleteAlarm(id){
|
async function deleteAlarm(id){
|
||||||
const response = await fetch("http://127.0.0.1:5000/deletealarm", {
|
const response = await fetch("http://127.0.0.1:5000/deletealarm", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: id,
|
body: id,
|
||||||
});
|
});
|
||||||
|
reloadAlarms();
|
||||||
|
}
|
||||||
|
|
||||||
|
function reloadAlarms(){
|
||||||
fetch("/processAlarm", {
|
fetch("/processAlarm", {
|
||||||
method: "GET"
|
method: "GET"
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
|
@ -105,6 +94,7 @@
|
||||||
.then(html => {
|
.then(html => {
|
||||||
previousAlarms.innerHTML = html
|
previousAlarms.innerHTML = html
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkAlarms(){
|
function checkAlarms(){
|
||||||
|
|
Loading…
Reference in New Issue