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

Binary file not shown.

Binary file not shown.

BIN
dist/fitra-linux-amd64 vendored

Binary file not shown.

BIN
dist/fitra-linux-arm64 vendored

Binary file not shown.

View File

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

View File

@@ -98,7 +98,7 @@ curl -O {{.BaseURL}}/uploads/abc123.../myfile.txt</code></pre>
<script> <script>
async function loadStorageInfo() { async function loadStorageInfo() {
try { try {
const response = await fetch('{{.BaseURL}}/storage'); const response = await fetch('/storage');
const data = await response.json(); const data = await response.json();
const storage = data.storage; const storage = data.storage;