package main
import (
"embed"
"github.com/gin-gonic/gin"
"html/template"
"log"
"net/http"
)
//go:embed templates/**/*.html
var templates embed.FS
//go:embed static/*
var staticFiles embed.FS
func main() {
r := gin.Default()
r.StaticFS("/static", http.FS(staticFiles))
tmpl, err := template.ParseFS(templates, "templates/**/*.html")
if err != nil {
log.Fatal(err)
}
r.SetHTMLTemplate(tmpl)
r.GET("/", func(c *gin.Context) {
c.HTML(http.StatusOK, "index.html", nil)
})
log.Fatal(r.Run(":9191"))
}
image.png
网友评论