Files
p/main.go

28 lines
502 B
Go
Raw Normal View History

2024-11-21 14:59:10 -08:00
package main
import (
"fmt"
"net/http"
"os"
)
func main() {
2024-11-21 19:30:11 -08:00
// http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
// fmt.Fprintf(w, "Hello! you've requested %s\n", r.URL.Path)
// })
2024-11-21 14:59:10 -08:00
2024-11-21 19:30:11 -08:00
http.Handle("/", http.FileServer(http.Dir("./static")))
2024-11-21 14:59:10 -08:00
port := os.Getenv("PORT")
if port == "" {
port = "80"
}
bindAddr := fmt.Sprintf(":%s", port)
fmt.Printf("==> Server listening at %s 🚀\n", bindAddr)
if err := http.ListenAndServe(bindAddr, nil); err != nil {
panic(err)
}
}