29 lines
689 B
Go
29 lines
689 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"log"
|
|
"net/http"
|
|
)
|
|
|
|
func main() {
|
|
log.SetFlags(log.LstdFlags | log.Lmicroseconds)
|
|
|
|
listenAddr := flag.String("listen", defaultListen, "web UI listen address, for example 127.0.0.1:18080")
|
|
flag.Parse()
|
|
|
|
application := newApp()
|
|
|
|
mux := http.NewServeMux()
|
|
mux.HandleFunc("/", application.handleIndex)
|
|
mux.HandleFunc("/start", application.handleStart)
|
|
mux.HandleFunc("/stop", application.handleStop)
|
|
|
|
log.Printf("web UI listening at http://%s", *listenAddr)
|
|
log.Printf("open the address in your browser and configure the watcher there")
|
|
|
|
if err := http.ListenAndServe(*listenAddr, mux); err != nil {
|
|
log.Fatalf("web server stopped: %v", err)
|
|
}
|
|
}
|