provide command line application, print info about directory

This commit is contained in:
gutmet 2018-12-09 11:40:26 +01:00
parent 664e291742
commit cfaa4c3285
2 changed files with 16 additions and 1 deletions

15
cmd/simpleserver.go Normal file
View File

@ -0,0 +1,15 @@
package main
import (
"fmt"
"git.gutmet.org/simpleserver.git"
"os"
)
func main() {
if len(os.Args) != 2 {
fmt.Println("Usage: " + os.Args[0] + " DIR")
os.Exit(1)
}
simpleserver.Serve(os.Args[1])
}

View File

@ -26,7 +26,7 @@ func viewHandler(root string, w http.ResponseWriter, r *http.Request) {
func Serve(root string) {
address := "0.0.0.0:8000"
fmt.Println("Serving at http://" + address + " ...")
fmt.Println("Serving " + root + " at http://" + address + " ...")
fmt.Println("Use Ctrl+C to exit")
fmt.Println("(This is not a production web server, don't get any funny ideas)")
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { viewHandler(root, w, r) })