Last active
February 3, 2017 12:37
-
-
Save ngmachado/c33bf758a0b37a030560525af2c6e3bb to your computer and use it in GitHub Desktop.
bare-fileserver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"log" | |
"net/http" | |
"path/filepath" | |
) | |
var ( | |
addr = flag.String("addr", ":3001", "addr") | |
root = flag.String("root", "./public", "site root") | |
) | |
func main() { | |
flag.Parse() | |
doc, err := filepath.Abs(*root) | |
if err != nil { | |
log.Fatal(err) | |
} | |
log.Printf("Ground control to Major Tom [%s]", *addr) | |
log.Fatal(http.ListenAndServe(*addr, http.FileServer(http.Dir(doc)))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment