1 // Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
13 var addr = flag.String("addr", ":8080", "http service address")
15 func serveHome(w http.ResponseWriter, r *http.Request) {
17 if r.URL.Path != "/" {
18 http.Error(w, "Not found", http.StatusNotFound)
21 if r.Method != "GET" {
22 http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
25 http.ServeFile(w, r, "home.html")
32 http.HandleFunc("/", serveHome)
33 http.HandleFunc("/ws", func(w http.ResponseWriter, r *http.Request) {
36 err := http.ListenAndServe(*addr, nil)
38 log.Fatal("ListenAndServe: ", err)