update
This commit is contained in:
@@ -1,13 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"flag"
|
||||
"gin-article/handler"
|
||||
"html/template"
|
||||
"io/fs"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"sync"
|
||||
@@ -16,11 +12,7 @@ import (
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
//go:embed tmpl/* statics/**/*
|
||||
var f embed.FS
|
||||
|
||||
func main() {
|
||||
|
||||
err := godotenv.Load(".env")
|
||||
if err != nil {
|
||||
log.Fatal("Error loading .env file")
|
||||
@@ -28,14 +20,6 @@ func main() {
|
||||
}
|
||||
|
||||
r := Router()
|
||||
// 静态文件也打包
|
||||
tmpl, _ := template.ParseFS(f, "tmpl/*")
|
||||
r.SetHTMLTemplate(tmpl)
|
||||
staticsFS, _ := fs.Sub(f, "statics")
|
||||
r.StaticFS("/statics", http.FS(staticsFS))
|
||||
|
||||
//r.LoadHTMLGlob("tmpl/*")
|
||||
//r.Static("/statics", "./statics")
|
||||
|
||||
port := flag.Int("p", 88, "the port to listen on")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user