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

This commit is contained in:
Kekskurse 2022-01-16 12:27:54 +01:00
parent 36c5bd2b48
commit b03404b2cc
Signed by: kekskurse
GPG key ID: 728ACCB59341E7E4
2 changed files with 40 additions and 2 deletions

19
main.go
View file

@ -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
View 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: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
</script>
</body>