From 9c2ad91230d72fe6d661450cc78300ea223ae2bc Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Mon, 19 Oct 2020 11:05:36 +0530 Subject: make it better --- main.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 main.go (limited to 'main.go') diff --git a/main.go b/main.go new file mode 100644 index 0000000..d1bbdf9 --- /dev/null +++ b/main.go @@ -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) +} -- cgit v1.2.3