Better location for static path
This commit is contained in:
parent
7d82fbf5e7
commit
08fb2ad37c
8
main.go
8
main.go
@ -50,7 +50,13 @@ func main() {
|
|||||||
log.Println("Registering handlers...")
|
log.Println("Registering handlers...")
|
||||||
authFunc := func (r *http.Request) (*User){ return Authenticate(*htpasswd, r) }
|
authFunc := func (r *http.Request) (*User){ return Authenticate(*htpasswd, r) }
|
||||||
|
|
||||||
staticDir, _ := filepath.Abs(filepath.Join(filepath.Dir(os.Args[0]), "static"))
|
staticDir, _ := filepath.Abs("static")
|
||||||
|
if _, err := os.Stat(staticDir); os.IsNotExist(err) {
|
||||||
|
staticDir, _ = filepath.Abs(filepath.Join(filepath.Dir(os.Args[0]), "static"))
|
||||||
|
if _, err := os.Stat(staticDir); os.IsNotExist(err) {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { http.ServeFile(w, r, filepath.Join(staticDir, "index.html")) })
|
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { http.ServeFile(w, r, filepath.Join(staticDir, "index.html")) })
|
||||||
|
Loading…
x
Reference in New Issue
Block a user