import (
"net/http"
)
func main() {
http.Handle("/", http.FileServer(http.Dir("static")))
http.ListenAndServe(":8080", nil)
}
I navigate to localhost:8080/ and get a 404 error. What am i doing wrong?
import (
"net/http"
)
func main() {
http.Handle("/", http.FileServer(http.Dir("static")))
http.ListenAndServe(":8080", nil)
}
I navigate to localhost:8080/ and get a 404 error. What am i doing wrong?
Try this:
import (
"net/http"
"os"
)
func main() {
server.RegisterHandlers()
// Get the running directory.
runningDirectory, err := os.Getwd()
if err != nil {
// Handle the error.
return err
}
http.Handle("/", http.FileServer(http.Dir(runningDirectory + "/static"))
http.ListenAndServe(":8080", nil)
}