-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
36 lines (29 loc) · 837 Bytes
/
main.go
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
29
30
31
32
33
34
35
36
package main
import (
"flag"
"fmt"
"log"
"os"
)
var servedDir string
var listenPort uint
var listenAddress string
func init() {
flag.StringVar(&servedDir, "served-dir", "", "Directory to serve contents from, defaults to CWD")
flag.UintVar(&listenPort, "listen-port", 3000, "Port to listen on, defaults to 3000")
flag.StringVar(&listenAddress, "listen-address", "", "Address to listen on, defaults to any (0.0.0.0)")
flag.Parse()
if servedDir == "" {
var err error
if servedDir, err = os.Getwd(); err != nil {
log.Fatalf("Could not discover current working directory: %s\n", err)
}
}
}
func main() {
log.Println("server starting")
if err := NewServer(fmt.Sprintf("%s:%d", listenAddress, listenPort), servedDir).Start(); err != nil {
log.Fatalf("server failed: %s\n", err)
}
log.Println("server exiting")
}