Remove SSL, serve static index.html
This commit is contained in:
parent
e5c38a85a8
commit
c71ce9fc2e
|
@ -120,7 +120,7 @@
|
||||||
this.psi.set(0); // set actual value
|
this.psi.set(0); // set actual value
|
||||||
|
|
||||||
// Set up websocket connection
|
// 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('open', this.gotWsOpen );
|
||||||
this.sock.addEventListener('message', this.gotWsMessage);
|
this.sock.addEventListener('message', this.gotWsMessage);
|
||||||
this.sock.addEventListener('error', this.gotWsError);
|
this.sock.addEventListener('error', this.gotWsError);
|
||||||
|
|
11
main.go
11
main.go
|
@ -49,9 +49,18 @@ var upgrader = websocket.Upgrader{
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
http.HandleFunc("/ws", subscribe)
|
http.HandleFunc("/ws/", subscribe)
|
||||||
|
http.HandleFunc("/", serveIndex)
|
||||||
log.Fatal(http.ListenAndServe("localhost:9888", nil))
|
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) {
|
func subscribe(w http.ResponseWriter, r *http.Request) {
|
||||||
c, err := upgrader.Upgrade(w, r, nil)
|
c, err := upgrader.Upgrade(w, r, nil)
|
||||||
|
|
Loading…
Reference in New Issue