display total number of events stored on welcome page
This commit is contained in:
parent
3e69086ada
commit
437d7bd4d8
@ -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")
|
||||
|
Loading…
x
Reference in New Issue
Block a user