about summary refs log tree commit diff homepage
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..656b816
--- /dev/null
+++ b/main.go
@@ -0,0 +1,30 @@
+package main
+
+import (
+	"embed"
+	"html/template"
+	"log"
+	"net/http"
+	"os"
+)
+
+//go:embed static/*
+var static embed.FS
+
+//go:embed templates/*.html
+var templates embed.FS
+
+func main() {
+	http.Handle("/static/", http.FileServer(http.FS(static)))
+	t, err := template.ParseFS(templates, "templates/*.html")
+	if err != nil {
+		log.Fatal(err)
+	}
+	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
+		t.ExecuteTemplate(w, "index.html", "Phylactery")
+	})
+
+	addr := os.Getenv("PHYLACTERY_ADDRESS")
+	log.Println("Listening on", addr)
+	log.Fatal(http.ListenAndServe(addr, nil))
+}