Created
October 6, 2014 16:24
-
-
Save apriendeau/fd91da6928228c4221b8 to your computer and use it in GitHub Desktop.
Gin html render example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>{{.title}}</title> | |
</head> | |
<body> | |
<h1>Hello World</h1> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "github.com/gin-gonic/gin" | |
func main() { | |
r := gin.Default() | |
r.LoadHTMLTemplates("templates/*") | |
r.GET("/index", func(c *gin.Context) { | |
obj := gin.H{"title": "Main website"} | |
c.HTML(200, "index.tmpl", obj) | |
}) | |
// Listen and server on 0.0.0.0:8080 | |
r.Run(":8080") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment