dip/dip.go
2020-01-26 16:38:57 +01:00

46 lines
923 B
Go

package main
import (
"flag"
"fmt"
//"io/ioutil"
//"os"
//"strings"
"github.com/gobuffalo/packr/v2"
"github.com/labstack/echo/v4"
//"github.com/markbates/pkger"
)
func main() {
e := echo.New()
e.HideBanner = true
var host, port string
flag.Usage = Usage
flag.StringVar(&host, "host", "[::]", "Listen host")
flag.StringVar(&port, "port", "8080", "Listen port")
flag.Parse()
templatesbox := packr.New("templates", "./templates")
staticbox := packr.New("static", "./static")
//t := pkger.Dir("/templatefiles")
//fmt.Println(t)
//test2,_ := t.Open("index.html")
//test3,_ := ioutil.ReadAll(test2)
//fmt.Println(string(test3))
//io.Copy(os.Stdout,test2)
builtTemplates, _ := BuildTemplates(templatesbox)
e.Renderer = builtTemplates
e.GET("/", Dip)
e.GET("/static/*", func(c echo.Context) error {
return Static(staticbox, c)
})
e.Logger.Fatal(e.Start(fmt.Sprintf("%s:%s", host, port)))
}