aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorVidhu Kant Sharma <bokuwakanojogahoshii@yahoo.com>2021-04-08 19:11:50 +0530
committerVidhu Kant Sharma <bokuwakanojogahoshii@yahoo.com>2021-04-08 19:11:50 +0530
commitb33e3fe60f4ae7eff88ab1ca28f45f94d2d9d713 (patch)
tree6601b8207d3b1618eca119419a7a3d8a6864d0ed /main.go
initial commit
Diffstat (limited to 'main.go')
-rw-r--r--main.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..168c98a
--- /dev/null
+++ b/main.go
@@ -0,0 +1,44 @@
+package main
+
+import (
+ "github.com/gin-gonic/gin"
+ "net/http"
+ //"os"
+ "fmt"
+)
+
+func main() {
+ // Set Gin to production mode
+ // gin.SetMode(gin.ReleaseMode)
+ var port string = "8080"
+// var port string = os.Getenv("PORT")
+ router := gin.New()
+ router.Use(gin.Logger())
+ router.LoadHTMLGlob("templates/*")
+
+ // css static routes
+ router.Static("/css", "static/css")
+ router.Static("/old/css", "static/css/old")
+ // js static routes
+ /*router.Static("/scripts", "static/scripts")
+ router.Static("/media", "static/media")*/
+
+ // serve classic themed pages
+ router.GET("/old", func (c *gin.Context) {
+ c.Redirect(http.StatusMovedPermanently, "/old/en")
+ })
+ router.GET("/old/en", func (c *gin.Context) {
+ c.HTML(http.StatusOK, "en.index.html", nil)
+ })
+ router.GET("/old/jp", func (c *gin.Context) {
+ c.HTML(http.StatusOK, "jp.index.html", nil)
+ })
+
+ router.POST("/old/submit", func (c *gin.Context) {
+ // do something else plz
+ var name string = c.PostForm("name")
+ fmt.Println(name)
+ })
+
+ router.Run(":" + port)
+}