-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.go
39 lines (36 loc) · 908 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
37
38
39
package main
import (
"fmt"
"log"
"net/http"
"os"
"strings"
"github.com/dyweb/gommon/noodle/_examples/embed/gen"
)
// use local folder dev, use embed when prod
func main() {
mode := "dev"
if len(os.Args) > 1 {
if strings.HasPrefix(os.Args[1], "p") {
mode = "prod"
}
}
var root http.FileSystem
if mode == "dev" {
// NOTE: if you are running it in IDE, use the following full path instead of relative path
//localDir := os.Getenv("GOPATH") + "/src/github.com/dyweb/gommon/noodle/_examples/embed/assets"
localDir := "assets"
root = http.Dir(localDir)
//root = noodle.NewLocal("assets")
} else {
bowel1, err := gen.GetNoodleAssets()
if err != nil {
log.Fatal(err)
}
root = &bowel1
}
addr := ":8080"
fmt.Printf("listen on %s in %s mode\n", addr, mode)
fmt.Printf("use http://localhost:8080/index.html")
log.Fatal(http.ListenAndServe(addr, http.FileServer(root)))
}