Example #1
0
func main() {
	flag.Parse()
	log.SetFlags(log.LstdFlags | log.Lshortfile)

	db, err := ndb.ReadDatabase("./data/")
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("Starting HTTP server on port %d", *port)
	server := frontend.NewServer(db, "./static/")
	if err := http.ListenAndServe(fmt.Sprintf(":%d", *port), server); err != nil {
		log.Fatal(err)
	}
}
Example #2
0
func init() {
	f, err := os.Open("./asciidb.gob.gz")
	if err != nil {
		panic(err)
	}
	defer f.Close()

	r, err := gzip.NewReader(f)
	if err != nil {
		panic(err)
	}
	defer r.Close()

	var db *ndb.ASCIIDB
	dec := gob.NewDecoder(r)
	if err = dec.Decode(&db); err != nil {
		panic(err)
	}

	db.RebuildSearchIndex()

	server := frontend.NewServer(db, "__served_by_appengine__")
	http.Handle("/", server)
}