Support serving a static directory along with the websocket stream

This commit is contained in:
Ian Gulliver
2016-03-10 21:44:00 -08:00
parent 521cc806fb
commit c1fc51fddf

View File

@@ -7,13 +7,19 @@ import (
)
var bindaddr = flag.String("bind-address", ":8080", "Address to respond to HTTP requests on")
var staticdir = flag.String("static-dir", "", "Static directory to serve at /")
func main() {
log.SetFlags(0)
flag.Parse()
go h.run()
go readInput()
http.HandleFunc("/stream", serveStream)
if *staticdir != "" {
fs := http.FileServer(http.Dir(*staticdir))
http.Handle("/", fs)
}
err := http.ListenAndServe(*bindaddr, nil)
if err != nil {
log.Fatal("Error starting web server: ", err)