about summary refs log tree commit diff
path: root/main.go
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2020-04-30 20:05:27 +0200
committerEmile <hanemile@protonmail.com>2020-04-30 20:05:27 +0200
commit25bbfaa9dc7a56e7df27bfe8e42a772286ffff74 (patch)
treea353712a13afc324b270926075d5ff689189f52d /main.go
parent7e7ac716629206a75ce308c775ab2c6eeeaaaa52 (diff)
super simple minimal setup
Diffstat (limited to 'main.go')
-rw-r--r--main.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..de5d97f
--- /dev/null
+++ b/main.go
@@ -0,0 +1,28 @@
+package main
+
+import (
+	"flag"
+	"fmt"
+	"log"
+	"net/http"
+
+	"github.com/gorilla/mux"
+)
+
+func main() {
+
+	// define the flags
+	ip := flag.String("ip", "0.0.0.0", "ip to listen on")
+	port := flag.String("p", "8087", "port to listen on")
+	dir := flag.String("dir", "./", "path to host")
+	flag.Parse()
+
+	// define the http server
+	r := mux.NewRouter()
+	r.Handle("/", http.FileServer(http.Dir(*dir)))
+	httpServer := http.Server{
+		Addr:    fmt.Sprintf("%s:%s", *ip, *port),
+		Handler: r,
+	}
+	log.Fatal(httpServer.ListenAndServe())
+}