Made assets accessible

This commit is contained in:
2026-06-05 19:09:41 +02:00
parent 1a0797ef19
commit 978ba292a1
4 changed files with 11 additions and 1 deletions

View File

@@ -3,6 +3,8 @@ package frontend
import (
"html/template"
"net/http"
"path/filepath"
"strings"
)
var dashbaord = template.Must(template.ParseFiles(
@@ -33,3 +35,8 @@ func Dashboard(w http.ResponseWriter, r *http.Request) {
return
}
}
func Assets(w http.ResponseWriter, r *http.Request) {
path := strings.TrimPrefix(r.URL.Path, "/assets/")
http.ServeFile(w, r, filepath.Join("frontend/assets", path))
}

View File

@@ -7,7 +7,7 @@
<script src="https://unpkg.com/htmx.org@2.0.4"></script>
<link rel="stylesheet" href="/static/css/app.css">
<link rel="stylesheet" href="/assets/css/dashboard.css">
</head>
<body>

View File

@@ -77,6 +77,9 @@ func (this *Server) Run() {
mux.HandleFunc("/api/stock/add", handlers.AddStock)
mux.HandleFunc("/api/project-items/add", handlers.AllocateToProject)
// Assets
mux.HandleFunc("/assets/", frontend.Assets)
// Login required
// Admin-only