package main import ( "flag" "fmt" "log" "net/http" "os" "path/filepath" ); func main() { port := flag.String("p", "8035", "port to serve on") file := flag.String("file", ".", "file to serve"); flag.Parse(); fi, err := os.Stat(*file); if (err != nil) { fmt.Println(err); return } if (!fi.Mode().IsRegular()) { fmt.Printf("File %s is not a file.", *file); return } *file, _ = filepath.Abs(*file); log.Printf("Attempting to run getfile at port %s with file %s\n", *port, *file); //http.Handle("/", http.FileServer(http.Dir("."))); http.HandleFunc("/", func (res http.ResponseWriter, req *http.Request) { log.Printf("called"); http.ServeFile(res, req, *file); }); log.Fatal(http.ListenAndServe(":"+*port, nil)); }