blob: de5d97fef7c0e41994eb481855d945fd4ffde170 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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())
}
|