about summary refs log tree commit diff homepage
path: root/main.go
blob: 656b81648a1e1b2df5157da14b32b16c240f5131 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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))
}