fyp/main.go

27 lines
500 B
Go

package main
import (
"fmt"
"net/http"
)
func main() {
fmt.Println("Starting server on :8000!")
handle := NewHandler()
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}
}
w.Header().Set("Location", "/")
w.WriteHeader(http.StatusSeeOther)
return nil
})
handle.Startup()
}