Directory Server in Go
-
I've been spending time learning Go and here's a small utility I wrote that's similar to Python's SimpleHTTPServer.
package main import ( "log" "net/http" "os" ) func main() { if len(os.Args) < 2 { log.Fatal("You must enter a path") } path := os.Args[1] http.Handle("/", http.FileServer(http.Dir(path))) http.ListenAndServe(":8000", nil) }
This creates an HTTP server serving all of the files in the path you specify.
Just use this:
go run serve.go /etc
Or do go build serve.go and it will create a binary you can run.