2023-09-18 00:26:42 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
fmt.Println("Starting server on :8000!")
|
|
|
|
|
2023-09-18 13:50:03 +01:00
|
|
|
handle := NewHandler()
|
2023-09-18 00:26:42 +01:00
|
|
|
|
2023-09-18 13:50:03 +01:00
|
|
|
handle.GetHTML("/", AnswerTemplate("index.html", nil))
|
|
|
|
handle.GetHTML("/login", AnswerTemplate("login.html", nil))
|
|
|
|
handle.Post("/login", func(mode AnswerType, w http.ResponseWriter, r *http.Request) *Error {
|
|
|
|
if mode == JSON {
|
|
|
|
return &Error{code: 404}
|
|
|
|
}
|
2023-09-18 00:26:42 +01:00
|
|
|
|
2023-09-18 13:50:03 +01:00
|
|
|
w.Header().Set("Location", "/")
|
|
|
|
w.WriteHeader(http.StatusSeeOther)
|
|
|
|
return nil
|
|
|
|
})
|
2023-09-18 00:26:42 +01:00
|
|
|
|
2023-09-18 13:50:03 +01:00
|
|
|
handle.Startup()
|
2023-09-18 00:26:42 +01:00
|
|
|
}
|