diff --git a/index.html b/index.html
index 2ded946..ab5ccf0 100644
--- a/index.html
+++ b/index.html
@@ -120,7 +120,7 @@
this.psi.set(0); // set actual value
// Set up websocket connection
- this.sock = new WebSocket("wss://" + window.location.hostname + "/ws/");
+ this.sock = new WebSocket("ws://" + window.location.hostname + ":9888/ws/");
this.sock.addEventListener('open', this.gotWsOpen );
this.sock.addEventListener('message', this.gotWsMessage);
this.sock.addEventListener('error', this.gotWsError);
diff --git a/main.go b/main.go
index ac4ccc9..a5e68c0 100644
--- a/main.go
+++ b/main.go
@@ -49,9 +49,18 @@ var upgrader = websocket.Upgrader{
}
func main() {
- http.HandleFunc("/ws", subscribe)
+ http.HandleFunc("/ws/", subscribe)
+ http.HandleFunc("/", serveIndex)
log.Fatal(http.ListenAndServe("localhost:9888", nil))
}
+func serveIndex(w http.ResponseWriter, r *http.Request) {
+ f, err := os.Open("index.html")
+ if err != nil {
+ http.Error(w, "Internal Server Error", http.StatusInternalServerError)
+ return
+ }
+ io.Copy(w, f)
+}
func subscribe(w http.ResponseWriter, r *http.Request) {
c, err := upgrader.Upgrade(w, r, nil)