Stuff
All checks were successful
continuous-integration/drone/push Build is passing

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" "net/http"
) )
var lastData interface{} var lastData map[string]interface{}
//go:embed notfall.tmpl //go:embed notfall.tmpl
var templateContent []byte 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) http.ListenAndServe(":8080", nil)
} }

View file

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