is-critter/backend/main.go
Vincent Batts c811d35fa5
backend: WIP
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2023-09-15 06:39:54 -04:00

30 lines
582 B
Go

package main
import (
"net/http"
"text/template"
"github.com/gorilla/mux"
"github.com/redis/go-redis/v9"
)
var (
client *redis.Client
templates *template.Template
)
func main() {
client = redis.NewClient(&redis.Options{
Addr: "localhost:6379",
DB: 0,
})
templates = template.Must(template.ParseGlob("templates/*.html"))
r := mux.NewRouter()
r.HandleFunc("/", indexHandler).Methods("GET")
http.Handle("/", r)
http.ListenAndServe(":8080", nil)
}
func indexHandler(w http.ResponseWriter, r *http.Request) {
templates.ExecuteTemplate(w, "index.html", nil)
}