From 2c078285b8c452ad544e01f5cdebd5e00a606595 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Fri, 29 Sep 2023 21:13:53 -0500 Subject: [PATCH] Embed template for single-binary deploys --- templates/index.html => index.html | 0 minecraft-site.go | 6 +++++- 2 files changed, 5 insertions(+), 1 deletion(-) rename templates/index.html => index.html (100%) diff --git a/templates/index.html b/index.html similarity index 100% rename from templates/index.html rename to index.html diff --git a/minecraft-site.go b/minecraft-site.go index 4794928..a653bee 100644 --- a/minecraft-site.go +++ b/minecraft-site.go @@ -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) }