diff options
Diffstat (limited to 'src/web.go')
-rw-r--r-- | src/web.go | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -37,6 +37,7 @@ func (server *WebServer) run() { router.Get("/", indexHandler) router.Get("/css/birdscan.css", cssHandler) router.Get("/js/birdscan.js", jsHandler) + router.Post("/api/state", stateHandler) router.Post("/api/single_picture", singlePictureHandler) log.Println("Binding to 'http://" + server.config.BindAddress + ":" + server.config.BindPort + "'") @@ -55,8 +56,12 @@ func jsHandler(w http.ResponseWriter, r *http.Request) { http.ServeFile(w, r, fmt.Sprintf("%s/js/birdscan.js", APP_DATA)) } +func stateHandler(w http.ResponseWriter, r *http.Request) { + known_state := r.FormValue("known_state") + w.Write([]byte(fmt.Sprintf("%s", camera.GetStateOnChange(known_state)))) +} + func singlePictureHandler(w http.ResponseWriter, r *http.Request) { - log.Println("Received request for a single picture") camera.SendEvent("take_single_picture") fmt.Fprintf(w, http.StatusText(http.StatusOK)) } |