首次提交:初始化项目代码
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
//go:embed web
|
||||
var webAssets embed.FS
|
||||
|
||||
func serveHTML(c *gin.Context, name string) {
|
||||
content, err := webAssets.ReadFile(name)
|
||||
if err != nil {
|
||||
c.String(http.StatusNotFound, "not found")
|
||||
return
|
||||
}
|
||||
c.Data(http.StatusOK, "text/html; charset=utf-8", content)
|
||||
}
|
||||
Reference in New Issue
Block a user