Embed template for single-binary deploys

This commit is contained in:
Chandler Swift 2023-09-29 21:13:53 -05:00
parent c97321beae
commit 2c078285b8
Signed by: chandlerswift
GPG key ID: A851D929D52FB93F
2 changed files with 5 additions and 1 deletions

View file

@ -2,6 +2,7 @@ package main
import (
"crypto/tls"
_ "embed"
"encoding/json"
"fmt"
"html/template"
@ -35,6 +36,9 @@ type pageData struct {
Servers []server
}
//go:embed index.html
var indexhtml string
func main() {
// Parse config file
@ -63,7 +67,7 @@ func main() {
// Set up templates
fmt.Print("Parsing templates...\n")
t, err := template.ParseFiles("templates/index.html")
t, err := template.New("").Parse(indexhtml)
if err != nil {
log.Fatalf("Error parsing HTML template: %v\n", err)
}