package main import ( "encoding/json" "net/http" "os" "github.com/gin-gonic/gin" ) func main() { router := gin.Default() // Static Folders router.StaticFS("/static", http.Dir("static")) // Templates Folders router.LoadHTMLGlob("templates/*") // Router Rules router.GET("/user/:uname", UnameFunc) router.GET("/", HomeFunc) router.Run(":8080") } // Func Rules func UnameFunc(c *gin.Context) { uname := c.Param("uname") c.String(http.StatusOK, "Hello %s", uname) } func HomeFunc(c *gin.Context) { type home_json struct { Title string Menu string } data_json, _ := os.ReadFile("data/web/home.json") var data home_json json.Unmarshal(data_json, &data) c.HTML(http.StatusOK, "home.html", data) }