Embed HTML
This commit is contained in:
BIN
dist/fitra-darwin-amd64
vendored
BIN
dist/fitra-darwin-amd64
vendored
Binary file not shown.
BIN
dist/fitra-darwin-arm64
vendored
BIN
dist/fitra-darwin-arm64
vendored
Binary file not shown.
BIN
dist/fitra-linux-amd64
vendored
BIN
dist/fitra-linux-amd64
vendored
Binary file not shown.
BIN
dist/fitra-linux-arm64
vendored
BIN
dist/fitra-linux-arm64
vendored
Binary file not shown.
9
main.go
9
main.go
@@ -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)
|
||||
|
||||
@@ -98,7 +98,7 @@ curl -O {{.BaseURL}}/uploads/abc123.../myfile.txt</code></pre>
|
||||
<script>
|
||||
async function loadStorageInfo() {
|
||||
try {
|
||||
const response = await fetch('{{.BaseURL}}/storage');
|
||||
const response = await fetch('/storage');
|
||||
const data = await response.json();
|
||||
const storage = data.storage;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user