Список жанров
+-
+ {{range .Genres}}
+
- {{.Name}} + {{end}} +
diff --git a/handlers.go b/handlers.go index 7f50d6b..2ea3d64 100644 --- a/handlers.go +++ b/handlers.go @@ -7,7 +7,7 @@ import ( func handleGenres(w http.ResponseWriter, r *http.Request) { if r.RequestURI != "/" { - http.Error(w, "not found", http.StatusNotFound) + http.FileServer(http.FS(stripSiteFS)).ServeHTTP(w, r) return } @@ -18,7 +18,7 @@ func handleGenres(w http.ResponseWriter, r *http.Request) { Domain: r.Host, Genres: Genres} - err := templates.Lookup("genres.html").Execute(w, data) + err := templates.Lookup("index.htm").Execute(w, data) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } diff --git a/main.go b/main.go index c90ab6c..0379977 100644 --- a/main.go +++ b/main.go @@ -1,19 +1,13 @@ package main import ( - "embed" "html/template" "log" "net/http" "os" "time" - - _ "embed" ) -//go:embed templates/genres.html -var templateBytes embed.FS - var templates *template.Template func init() { @@ -45,7 +39,7 @@ func init() { func initTepmplates() error { var err error - templates, err = template.ParseFS(templateBytes, "templates/*.html") + templates, err = template.ParseFS(siteFS, "site/*.htm") if err != nil { return err } diff --git a/site.go b/site.go new file mode 100644 index 0000000..c4c8140 --- /dev/null +++ b/site.go @@ -0,0 +1,15 @@ +package main + +import ( + "embed" + "io/fs" +) + +//go:embed site/* +var siteFS embed.FS + +var stripSiteFS fs.FS + +func init() { + stripSiteFS, _ = fs.Sub(siteFS, "site") +} diff --git a/site/favicon.svg b/site/favicon.svg new file mode 100644 index 0000000..5b668a6 --- /dev/null +++ b/site/favicon.svg @@ -0,0 +1 @@ + diff --git a/site/index.htm b/site/index.htm new file mode 100644 index 0000000..a305507 --- /dev/null +++ b/site/index.htm @@ -0,0 +1,24 @@ + + +
+ + +