aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorVidhu Kant Sharma <bokuwakanojogahoshii@yahoo.com>2020-10-19 11:05:36 +0530
committerVidhu Kant Sharma <bokuwakanojogahoshii@yahoo.com>2020-10-19 11:05:36 +0530
commit9c2ad91230d72fe6d661450cc78300ea223ae2bc (patch)
tree17bd774b3f972359dfbb46248f085bbf1c6dae98 /main.go
make it better
Diffstat (limited to 'main.go')
-rw-r--r--main.go30
1 files changed, 30 insertions, 0 deletions
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)
+}