Bläddra i källkod

Test web-server

Denis V. Dedkov 9 år sedan
förälder
incheckning
cb00d423e7
1 ändrade filer med 14 tillägg och 0 borttagningar
  1. 14 0
      noolite-cli.go

+ 14 - 0
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)
+	}
 }