display total number of events stored on welcome page

This commit is contained in:
mr0x50 2025-02-09 23:17:56 +01:00
parent 3e69086ada
commit 437d7bd4d8

View File

@ -60,7 +60,15 @@ func main() {
// set up other http handlers
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("content-type", "text/html")
fmt.Fprintf(w, `<b>Welcome</b> to scrapestr!`)
// Query the total number of events
count := 0
row := db.DB.QueryRow("SELECT COUNT(*) FROM event")
if err := row.Scan(&count); err != nil {
fmt.Printf("Error counting events: %v\n", err)
}
fmt.Fprintf(w, `<b>Welcome</b> to scrapestr!<br>Number of events stored: %d`, count)
})
fmt.Println("running on :3334")