Embed HTML

This commit is contained in:
2025-08-07 23:01:28 +02:00
parent f63826e2ea
commit 1232368e25
6 changed files with 9 additions and 2 deletions

View File

@@ -1,9 +1,11 @@
package main
import (
"embed"
"fitra-backend/application"
"fitra-backend/controllers"
"fmt"
"html/template"
"log"
"os"
@@ -11,6 +13,9 @@ import (
"github.com/joho/godotenv"
)
//go:embed views/*
var viewsFS embed.FS
func main() {
if err := godotenv.Load(); err != nil {
log.Println("No .env file found")
@@ -19,7 +24,9 @@ func main() {
go application.StartCleanupRoutine()
r := gin.Default()
r.LoadHTMLGlob("views/*")
tmpl := template.Must(template.New("").ParseFS(viewsFS, "views/*.html"))
r.SetHTMLTemplate(tmpl)
r.GET("/", controllers.HandleIndex)
r.POST("/upload", controllers.HandleFileUpload)