zdravko/cmd/server/main.go

31 lines
573 B
Go
Raw Normal View History

package main
import (
"log"
"net/http"
2024-02-11 09:15:00 +00:00
"os"
"github.com/gorilla/mux"
"code.tjo.space/mentos1386/zdravko/internal"
"code.tjo.space/mentos1386/zdravko/internal/pages"
)
func main() {
2024-02-11 09:15:00 +00:00
port := os.Getenv("PORT")
if port == "" {
port = "8000"
}
r := mux.NewRouter()
// Server static files
r.PathPrefix("/static/").Handler(http.FileServer(http.FS(internal.Static)))
r.HandleFunc("/", pages.Index).Methods("GET")
r.HandleFunc("/settings", pages.Settings).Methods("GET")
2024-02-11 09:15:00 +00:00
log.Println("Server started on", port)
log.Fatal(http.ListenAndServe(":"+port, r))
}