mmg/main.go

30 lines
684 B
Go

package main
import (
"flag"
"github.com/gorilla/sessions"
"log"
"net/http"
"math/rand"
"time"
)
const MAX = 12
var addr = flag.String("addr", ":8000", "address I'll listen on.")
var static_files = flag.String("static", "./static", "location of static files")
var store = sessions.NewCookieStore([]byte("hello world"))
func main() {
rand.Seed( time.Now().UTC().UnixNano())
flag.Parse()
http.Handle("/",
http.FileServer(http.Dir(*static_files)))
http.Handle("/api/v0/problem/", JsonHandler(problem))
http.Handle("/api/v0/attempt/", JsonHandler(attempt))
if err := http.ListenAndServe(*addr, nil); err != nil {
log.Fatal("ListenAndServe:", err)
}
}