simplify server
This commit is contained in:
parent
f702890d6b
commit
dc7cc9e7dc
1 changed files with 4 additions and 39 deletions
43
server.go
43
server.go
|
@ -5,8 +5,8 @@ import (
|
|||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/spatialfree/dofdev/src/router"
|
||||
"github.com/spatialfree/dofdev/tem"
|
||||
"dofdev/src/router"
|
||||
"dofdev/tem"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -18,44 +18,9 @@ func main() {
|
|||
r := router.New()
|
||||
|
||||
// Start the web server
|
||||
log.Println("server starting on port 3210...")
|
||||
addr := ":3210"
|
||||
// addr := "192.168.0.21:3000"
|
||||
addr := ":3232"
|
||||
log.Println("server starting on port" + addr)
|
||||
if err := http.ListenAndServe(addr, r); err != nil {
|
||||
log.Fatalf("error starting server: %v", err)
|
||||
}
|
||||
|
||||
// fs := http.FileServer(http.Dir("./res"))
|
||||
// http.Handle("/res/", http.StripPrefix("/res/", fs))
|
||||
|
||||
// http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
// fmt.Println("request: ", r.URL.Path)
|
||||
// http.ServeFile(w, r, "./index.html")
|
||||
// })
|
||||
|
||||
// http.HandleFunc("/pass", func(w http.ResponseWriter, r *http.Request) {
|
||||
// fmt.Println("request: ", r.URL.Path)
|
||||
// // fmt.Println("request: ", r.Header)
|
||||
// fmt.Println("request: ", r.FormValue("pass"))
|
||||
// fmt.Println("request: ", hash(r.FormValue("pass")))
|
||||
// if hash(r.FormValue("pass")) == 3556498 {
|
||||
// http.ServeFile(w, r, "./biz.html")
|
||||
// } else {
|
||||
// http.Error(w, "Forbidden", http.StatusForbidden)
|
||||
// }
|
||||
// })
|
||||
|
||||
// fmt.Println("server starting @ http://localhost:3210 ...")
|
||||
// if err := http.ListenAndServe(":3210", nil); err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
}
|
||||
|
||||
// hash function
|
||||
func hash(s string) uint32 {
|
||||
h := uint32(0)
|
||||
for i := 0; i < len(s); i++ {
|
||||
h = 31*h + uint32(s[i])
|
||||
}
|
||||
return h
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue