Skip to content

Instantly share code, notes, and snippets.

@NaniteFactory
Last active September 4, 2020 11:20
Show Gist options
  • Save NaniteFactory/447731150e1e7f313a4ae9087e5f4121 to your computer and use it in GitHub Desktop.
Save NaniteFactory/447731150e1e7f313a4ae9087e5f4121 to your computer and use it in GitHub Desktop.
fileserver written in go
package main
import (
"flag"
"log"
"net/http"
)
var (
listen = flag.String("listen", ":8080", "listen address")
dir = flag.String("dir", ".", "directory to serve")
)
func main() {
flag.Parse()
log.Printf("listening on %q...", *listen)
log.Fatal(http.ListenAndServe(*listen, http.FileServer(http.Dir(*dir))))
}
// $ fileserver -dir=. -listen=localhost:8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment