34 lines
1.0 KiB
Go
Raw Normal View History

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 (
"html/template"
2023-10-04 17:29:22 +02:00
"log"
"net/http"
"streifling.com/jason/sicherheitsunterweisung/packages/data"
"streifling.com/jason/sicherheitsunterweisung/packages/server"
2023-10-04 17:29:22 +02:00
)
func main() {
logins := make([]string, 0)
db, err := data.OpenDB("sicherheitsunterweisung")
if err != nil {
log.Fatalln(err)
}
2023-10-19 15:22:45 +02:00
mux := http.NewServeMux()
mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static/"))))
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
template.Must(template.ParseFiles("templates/index.html", "templates/login.html")).Execute(w, nil)
})
mux.HandleFunc("/search/", server.DisplaySearchResults(db))
mux.HandleFunc("/new-briefing/", server.DisplayInstructorForm())
mux.HandleFunc("/add-participant/", server.AddParticipant(&logins))
2023-10-19 15:22:45 +02:00
mux.HandleFunc("/submit-form/", server.SubmitBriefingForm(db, &logins))
mux.HandleFunc("/internal-login/", server.DisplayTable(db))
mux.HandleFunc("/external-login/", server.DisplayParticipantForm(&logins))
2023-10-04 17:29:22 +02:00
log.Fatalln(http.ListenAndServe(":8080", mux))
}