summaryrefslogtreecommitdiff
path: root/src/web.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/web.go')
-rw-r--r--src/web.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/web.go b/src/web.go
index 6515f47..206681d 100644
--- a/src/web.go
+++ b/src/web.go
@@ -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))
}