diff options
author | Vidhu Kant Sharma <bokuwakanojogahoshii@yahoo.com> | 2020-10-19 11:05:36 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <bokuwakanojogahoshii@yahoo.com> | 2020-10-19 11:05:36 +0530 |
commit | 9c2ad91230d72fe6d661450cc78300ea223ae2bc (patch) | |
tree | 17bd774b3f972359dfbb46248f085bbf1c6dae98 /main.go |
make it better
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -0,0 +1,30 @@ +package main + +import ( +// "log" + "net/http" + "os" + + "github.com/gin-gonic/gin" + _ "github.com/heroku/x/hmetrics/onload" +) + +func main() { + port := os.Getenv("PORT") + + if port == "" { + // log.Fatal("$PORT must be set") + port = "8080" + } + + router := gin.New() + router.Use(gin.Logger()) + router.LoadHTMLGlob("templates/*.html") + router.Static("/static", "static") + + router.GET("/", func(c *gin.Context) { + c.HTML(http.StatusOK, "index.html", nil) + }) + + router.Run(":" + port) +} |