61 lines
1.4 KiB
Go
61 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"net/http"
|
|
|
|
"github.com/spatialfree/dofdev/src/router"
|
|
"github.com/spatialfree/dofdev/tem"
|
|
)
|
|
|
|
func init() {
|
|
fmt.Println("init()")
|
|
tem.Load()
|
|
}
|
|
|
|
func main() {
|
|
r := router.New()
|
|
|
|
// Start the web server
|
|
log.Println("server starting on port 3210...")
|
|
addr := ":3210"
|
|
// addr := "192.168.0.21:3000"
|
|
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
|
|
}
|