aboutsummaryrefslogtreecommitdiff
path: root/main.go
blob: 168c98a9a992ac15a35105b50d3da7f16b12da67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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)
}