Stuff
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Kekskurse 2022-01-16 12:39:26 +01:00
parent b03404b2cc
commit afbe9e74a5
Signed by: kekskurse
GPG Key ID: 728ACCB59341E7E4
2 changed files with 23 additions and 1 deletions

17
main.go
View File

@ -8,7 +8,7 @@ import (
"net/http"
)
var lastData interface{}
var lastData map[string]interface{}
//go:embed notfall.tmpl
var templateContent []byte
@ -38,5 +38,20 @@ func main() {
})
})
http.HandleFunc("/json", func(writer http.ResponseWriter, request *http.Request) {
var data map[string]interface{}
data["lat"] = lastData["lat"]
data["lon"] = lastData["lon"]
data["tst"] = lastData["tst"]
r, err := json.Marshal(data)
if err != nil {
panic(err)
}
writer.Write(r)
})
http.ListenAndServe(":8080", nil)
}

View File

@ -19,5 +19,12 @@
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
function update() {
fetch('/json')
.then(response => response.json())
.then(data => console.log(data));
}
update()
</script>
</body>