From cb00d423e715c6f35e87e1e13d25ab7d516e32ce Mon Sep 17 00:00:00 2001 From: "Denis V. Dedkov" Date: Mon, 27 Jun 2016 22:17:39 +0500 Subject: [PATCH] Test web-server --- noolite-cli.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/noolite-cli.go b/noolite-cli.go index 5390274..640ac82 100644 --- a/noolite-cli.go +++ b/noolite-cli.go @@ -2,7 +2,9 @@ package main import ( "flag" + "fmt" "github.com/dedkovd/noolite" + "net/http" ) func main() { @@ -12,6 +14,9 @@ func main() { red := flag.Int("r", 0, "Red channel") green := flag.Int("g", 0, "Green channel") blue := flag.Int("b", 0, "Blue channel") + + http_port := flag.Int("p", -1, "Http port") + flag.Parse() if *channel == -1 { @@ -60,4 +65,13 @@ func main() { if err != nil { panic(err) } + + if *http_port != -1 { + http.HandleFunc("/switch", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "%q", r.URL.RawQuery) + n.Switch(7) + }) + + http.ListenAndServe(":8080", nil) + } }