Gin-返回数据-加载静态文件

Go-Gin

package main

import (
    "github.com/gin-gonic/gin"
    "net/http"
)

func main()  {
    app := gin.Default()
    // 指明html加载文件目录
    app.LoadHTMLGlob("./html/*")
    // 映射static静态文件目录
    app.Static("image", "./static") // 当客户端通过image路径访问静态文件时,服务端从"./static"目录读取静态文件
    app.Handle("GET", "/", func(context *gin.Context) {
        context.HTML(http.StatusOK, "index.html", nil)
    })
    app.Run()
}

HTML




    
    title


    


你可能感兴趣的:(Gin-返回数据-加载静态文件)