32 lines
612 B
Go
Raw Normal View History

package main
2023-06-02 04:32:10 +02:00
import (
"fmt"
"log"
"net/http"
)
type WebsiteStatus struct {
2023-06-02 15:47:33 +02:00
WebsiteURL string
2023-06-02 04:32:10 +02:00
Description string
HasIcon bool
2023-06-02 15:47:33 +02:00
IconURL string
2023-06-02 04:32:10 +02:00
}
func main() {
2023-06-02 15:47:33 +02:00
websites, err := readWebsitesFromFile("websites.conf")
if err != nil {
log.Fatal(err)
2023-06-02 04:32:10 +02:00
}
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
renderTemplate(w, websites)
2023-06-02 04:32:10 +02:00
})
http.HandleFunc("/check", handleCheck)
2023-06-02 04:32:10 +02:00
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))
fmt.Println("Server listening on http://localhost:8080")
2023-06-02 04:32:10 +02:00
log.Fatal(http.ListenAndServe(":8080", nil))
}