From c01a1e2cbdaf9da30a1c328bfb7f0afd42e59ba1 Mon Sep 17 00:00:00 2001 From: Brian Buller Date: Tue, 14 Apr 2015 15:21:11 -0500 Subject: [PATCH] Initial Commit --- main.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 main.go diff --git a/main.go b/main.go new file mode 100644 index 0000000..48e87ec --- /dev/null +++ b/main.go @@ -0,0 +1,27 @@ +package main + +import ( + "log" + "net/http" + "os" +) + +func main() { + args := os.Args[1:] + port := "8080" + if len(args) == 0 { + log.Println("Usage: quickhttp [port]") + os.Exit(1) + } + content_dir := args[0] + + if len(args) == 2 { + port = args[1] + } + + // Public Views + fs := http.FileServer(http.Dir(content_dir)) + http.Handle("/", fs) + log.Println("Listening...") + log.Fatal(http.ListenAndServe(":"+port, nil)) +} \ No newline at end of file