Gin-返回数据-HTML静态页面
2020-07-06 本文已影响0人
诗意_面包
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) {
// 返回HTML文件,响应状态码200,html文件名为index.html,模板参数为nil
context.HTML(http.StatusOK, "index.html", nil)
})
app.Run()
}