Support serving a static directory along with the websocket stream
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user