use go:embed to include forms.html into cpmpiled binary
This commit is contained in:
parent
f9295b74ee
commit
bd3b2817f2
1 changed files with 4 additions and 1 deletions
5
main.go
5
main.go
|
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"html/template"
|
||||
|
|
@ -97,6 +98,8 @@ type Source struct {
|
|||
var (
|
||||
mu sync.Mutex
|
||||
chars []Character
|
||||
//go:embed forms.html
|
||||
page embed.FS
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -112,7 +115,7 @@ func main() {
|
|||
// formHandler zeigt das Formular an
|
||||
func formHandler(filename string) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
tmpl, err := template.ParseFiles("forms.html")
|
||||
tmpl, err := template.ParseFS(page, "forms.html")
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue