package main import ( "fmt" "net/http" "os" "strconv" "mcquay.me/web" ) func main() { port := 8000 if os.Getenv("PORT") != "" { p, err := strconv.Atoi(os.Getenv("PORT")) if err != nil { fmt.Fprintf(os.Stderr, "couldn't parse port: %v\n", err) os.Exit(1) } port = p } static := "" if s := os.Getenv("STATIC"); s != "" { static = s } tmpl := "" if t := os.Getenv("TEMPLATES"); t != "" { tmpl = t } sm := http.NewServeMux() web.NewSite(sm, static, tmpl) if err := http.ListenAndServe(fmt.Sprintf(":%d", port), sm); err != nil { fmt.Fprintf(os.Stderr, "problem serving: %v\n", err) os.Exit(1) } }