38 lines
1.0 KiB
Go
38 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"html/template"
|
|
"log"
|
|
"net/http"
|
|
|
|
"streifling.com/jason/cpolis/cmd/data"
|
|
"streifling.com/jason/cpolis/cmd/feed"
|
|
"streifling.com/jason/cpolis/cmd/ui"
|
|
)
|
|
|
|
func main() {
|
|
db, err := data.OpenDB("cpolis")
|
|
if err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
defer db.Close()
|
|
|
|
rss, err := feed.OpenFeed("tmp/rss.gob")
|
|
if err != nil {
|
|
log.Println(err)
|
|
rss = feed.NewFeed("Freimaurer Distrikt Niedersachsen und Sachsen-Anhalt",
|
|
"https://distrikt-ni-st.de",
|
|
"Freiheit, Gleichheit, Brüderlichkeit, Toleranz und Humanität")
|
|
}
|
|
|
|
mux := http.NewServeMux()
|
|
mux.Handle("/web/static/", http.StripPrefix("/web/static/", http.FileServer(http.Dir("web/static/"))))
|
|
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
|
template.Must(template.ParseFiles("web/templates/index.html", "web/templates/login.html")).Execute(w, nil)
|
|
})
|
|
mux.HandleFunc("POST /login/", ui.HandleLogin(db))
|
|
mux.HandleFunc("POST /finished-edit/", ui.HandleFinishedEdit(rss))
|
|
|
|
log.Fatalln(http.ListenAndServe(":8080", mux))
|
|
}
|