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
|
|
|
|
|
|
|
"streifling.com/jason/sicherheitsunterweisung/db"
|
2023-10-05 18:08:44 +02:00
|
|
|
"streifling.com/jason/sicherheitsunterweisung/server"
|
2023-10-05 19:52:11 +02:00
|
|
|
"streifling.com/jason/sicherheitsunterweisung/types"
|
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-05 19:52:11 +02:00
|
|
|
cb := make(chan *types.Briefing)
|
2023-10-05 17:42:47 +02:00
|
|
|
|
2023-10-05 19:52:11 +02:00
|
|
|
db, err := db.OpenDB("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-05 18:27:21 +02:00
|
|
|
mux.HandleFunc("/", server.DisplayForm(&i))
|
|
|
|
mux.HandleFunc("/add-participant/", server.AddParticipant(&i))
|
2023-10-05 19:52:11 +02:00
|
|
|
mux.HandleFunc("/submit/", server.SubmitForm(cb, &i, &j))
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
for b := range cb {
|
|
|
|
db.WriteBriefing(b)
|
|
|
|
}
|
|
|
|
}()
|
2023-10-04 17:29:22 +02:00
|
|
|
|
|
|
|
log.Fatalln(http.ListenAndServe(":8080", mux))
|
|
|
|
}
|