mmg/main.go

30 lines
668 B
Go
Raw Normal View History

2013-05-08 22:43:18 -07:00
package main
import (
"flag"
"github.com/gorilla/sessions"
"log"
2013-05-09 00:48:56 -07:00
"math/rand"
2013-05-08 22:43:18 -07:00
"net/http"
2013-05-09 00:48:56 -07:00
"time"
2013-05-08 22:43:18 -07:00
)
2013-05-08 23:21:18 -07:00
const MAX = 12
2013-05-08 22:43:18 -07:00
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() {
2013-05-09 00:48:56 -07:00
rand.Seed(time.Now().UTC().UnixNano())
2013-05-08 22:43:18 -07:00
flag.Parse()
http.Handle("/",
http.FileServer(http.Dir(*static_files)))
2013-05-09 00:48:56 -07:00
http.Handle("/api/v0/problem/", JsonHandler(problem))
http.Handle("/api/v0/attempt/", JsonHandler(attempt))
2013-05-08 22:43:18 -07:00
if err := http.ListenAndServe(*addr, nil); err != nil {
log.Fatal("ListenAndServe:", err)
}
}