provide command line application, print info about directory
This commit is contained in:
parent
664e291742
commit
cfaa4c3285
15
cmd/simpleserver.go
Normal file
15
cmd/simpleserver.go
Normal 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])
|
||||
}
|
|
@ -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) })
|
||||
|
|
Loading…
Reference in New Issue
Block a user