Go-Gin
package main
import (
"github.com/gin-gonic/gin"
"net/http"
)
func main() {
app := gin.Default()
// 指明html加载文件目录
app.LoadHTMLGlob("./html/*")
app.Handle("GET", "/", func(context *gin.Context) {
context.HTML(http.StatusOK, "index.html", gin.H{
"title": "首页",
"fullpath": context.FullPath(),
})
})
app.Run()
}
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{.title}}</title>
</head>
<body>
<p>{{.fullpath}}</p>
</body>
</html>