This commit is contained in:
parent
b03404b2cc
commit
afbe9e74a5
2 changed files with 23 additions and 1 deletions
17
main.go
17
main.go
|
@ -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)
|
||||||
}
|
}
|
|
@ -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: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
attribution: '© <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>
|
Loading…
Reference in a new issue