gopher/examples/fileserver/main.go

30 lines
396 B
Go
Raw Normal View History

2016-09-14 03:45:49 +00:00
package main
import (
"flag"
"log"
"os"
"github.com/prologic/go-gopher"
)
func cwd() string {
dir, err := os.Getwd()
if err != nil {
log.Fatal(err)
}
return dir
}
func main() {
var (
root = flag.String("root", cwd(), "root directory to serve")
)
flag.Parse()
gopher.Handle("/", gopher.FileServer(gopher.Dir(*root)))
log.Fatal(gopher.ListenAndServe("localhost:70", nil))
}