mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-10 09:52:51 +00:00
updated saving temperatures end point
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -7,4 +7,5 @@ public
|
|||||||
npm-debug.log
|
npm-debug.log
|
||||||
mywebsite
|
mywebsite
|
||||||
tls.key
|
tls.key
|
||||||
tls.crt
|
tls.crt
|
||||||
|
stats.html
|
||||||
|
|||||||
@@ -27,6 +27,11 @@ func HandleSensorRequest(w http.ResponseWriter, r *http.Request, ps httprouter.P
|
|||||||
|
|
||||||
//get request parameters - convert temp to float64
|
//get request parameters - convert temp to float64
|
||||||
temperature, _ := strconv.ParseFloat(r.URL.Query().Get("temperature"), 64)
|
temperature, _ := strconv.ParseFloat(r.URL.Query().Get("temperature"), 64)
|
||||||
|
if temperature < -50 {
|
||||||
|
fmt.Fprint(w, "{ message: \"Bad temperature reading\"}")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
location := r.URL.Query().Get("location")
|
location := r.URL.Query().Get("location")
|
||||||
t := time.Now()
|
t := time.Now()
|
||||||
|
|
||||||
@@ -214,4 +219,4 @@ func createResponse(s []daily_sensor.Data, err error) string{
|
|||||||
}
|
}
|
||||||
|
|
||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user