2023-10-05 18:08:44 +02:00
|
|
|
package main
|
2023-10-04 17:13:03 +02:00
|
|
|
|
2023-10-04 17:29:22 +02:00
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"net/http"
|
2023-10-05 19:52:11 +02:00
|
|
|
|
2023-10-05 19:56:18 +02:00
|
|
|
"streifling.com/jason/sicherheitsunterweisung/packages/db"
|
|
|
|
"streifling.com/jason/sicherheitsunterweisung/packages/server"
|
2023-10-04 17:29:22 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2023-10-05 16:50:23 +02:00
|
|
|
var i, j int64
|
|
|
|
i, j = 1, 1
|
2023-10-05 17:42:47 +02:00
|
|
|
mux := http.NewServeMux()
|
|
|
|
|
2023-10-07 16:58:34 +02:00
|
|
|
db, err := db.Open("sicherheitsunterweisung")
|
2023-10-05 17:42:47 +02:00
|
|
|
if err != nil {
|
|
|
|
log.Fatalln(err)
|
2023-10-05 19:52:11 +02:00
|
|
|
}
|
2023-10-04 18:55:48 +02:00
|
|
|
|
|
|
|
mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static/"))))
|
2023-10-08 10:36:16 +02:00
|
|
|
mux.HandleFunc("/", server.DisplayTable(db))
|
|
|
|
mux.HandleFunc("/submit/", server.SubmitForm(db, &i, &j))
|
|
|
|
mux.HandleFunc("/search/", server.DisplayResults(db))
|
|
|
|
mux.HandleFunc("/new-briefing/", server.DisplayForm(&i))
|
2023-10-05 18:27:21 +02:00
|
|
|
mux.HandleFunc("/add-participant/", server.AddParticipant(&i))
|
2023-10-04 17:29:22 +02:00
|
|
|
|
|
|
|
log.Fatalln(http.ListenAndServe(":8080", mux))
|
|
|
|
}
|