I have a file C:\hello\index.go:
package main
import "net/http"
func main() {
http.Handle("/assets", http.FileServer(http.Dir("assets")))
println("ListenAndServe")
http.ListenAndServe(":9000", nil)
}
I enter go run index.go, then make this request:
PS C:\> curl localhost:9000/assets/kitten.jpg
404 page not found
I know the path is valid:
PS C:\> curl -I file:/C:/hello/assets/kitten.jpg
Content-Length: 3000898
Accept-ranges: bytes
Last-Modified: Sun, 16 Jan 2022 01:14:58 GMT
I also tried these other lines:
http.Handle("/assets", http.FileServer(http.Dir(`C:\hello\assets`)))
http.Handle("/assets/", http.FileServer(http.Dir("assets")))
http.Handle("/assets/", http.FileServer(http.Dir(`C:\hello\assets`)))
but I get 404 every time. What am I doing wrong?