This commit is contained in:
parent
36c5bd2b48
commit
b03404b2cc
2 changed files with 40 additions and 2 deletions
19
main.go
19
main.go
|
@ -1,26 +1,41 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
var lastData interface{}
|
var lastData interface{}
|
||||||
|
|
||||||
|
//go:embed notfall.tmpl
|
||||||
|
var templateContent []byte
|
||||||
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
http.HandleFunc("/owntrack", func(writer http.ResponseWriter, request *http.Request) {
|
http.HandleFunc("/owntrack", func(writer http.ResponseWriter, request *http.Request) {
|
||||||
var p interface{}
|
var p map[string]interface{}
|
||||||
err := json.NewDecoder(request.Body).Decode(&p)
|
err := json.NewDecoder(request.Body).Decode(&p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writer.WriteHeader(http.StatusInternalServerError)
|
writer.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if p["_type"] == "location"{
|
||||||
|
lastData = p
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Println(p)
|
fmt.Println(p)
|
||||||
|
|
||||||
|
writer.Write([]byte("[]"))
|
||||||
})
|
})
|
||||||
|
|
||||||
http.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) {
|
http.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) {
|
||||||
writer.Write([]byte("Hallo"))
|
templ := template.Must(template.New("page").Parse(string(templateContent)))
|
||||||
|
templ.Execute(writer, map[string]interface{}{
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
http.ListenAndServe(":8080", nil)
|
http.ListenAndServe(":8080", nil)
|
||||||
|
|
23
notfall.tmpl
Normal file
23
notfall.tmpl
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"
|
||||||
|
integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
|
||||||
|
crossorigin=""/>
|
||||||
|
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
|
||||||
|
integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
|
||||||
|
crossorigin=""></script>
|
||||||
|
|
||||||
|
<style type="text/css">
|
||||||
|
#map { height: 180px; }
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="map"></div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var map = L.map('map').setView([51.505, -0.09], 13);
|
||||||
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||||
|
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||||
|
}).addTo(map);
|
||||||
|
</script>
|
||||||
|
</body>
|
Loading…
Reference in a new issue