go-todos-app/main.go
Michael Thomson 44feca12d2
All checks were successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/dryrun Pipeline was successful
ci/woodpecker/push/publish-tag Pipeline was successful
ci/woodpecker/push/publish-latest Pipeline was successful
tailwind and docker update
2024-06-09 16:21:41 -04:00

32 lines
619 B
Go

package main
import (
"log"
"net/http"
"path/filepath"
"github.com/a-h/templ"
"michaelthomson.dev/mthomson/go-todos-app/views"
)
func main() {
router := http.NewServeMux()
// Serve static files
router.HandleFunc("GET /assets/", func(w http.ResponseWriter, r *http.Request) {
filePath := r.URL.Path[len("/assets/"):]
fullPath := filepath.Join(".", "assets", filePath)
http.ServeFile(w, r, fullPath)
})
home := views.Home()
router.Handle("GET /", templ.Handler(home))
server := http.Server{
Addr: "localhost:3000",
Handler: router,
}
log.Fatal(server.ListenAndServe())
}