Exemple #1
0
func main() {
	flag.Parse()

	if *dbFile == "" {
		fmt.Fprintln(os.Stderr, "must provide -db")
		os.Exit(1)
	}

	if db, err := model.Initialize(*dbFile); err != nil {
		fmt.Fprintln(os.Stderr, "Error initializing db:", err)
		os.Exit(1)
	} else {
		defer db.Close()
	}

	if *login == "" || *email == "" {
		fmt.Fprintln(os.Stderr, "must provide -login, -email")
		os.Exit(1)
	}

	pw, err := makepw()
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error creating password:"******"Error creating user:"******"Created user with password:", pw)
}
Exemple #2
0
func main() {
	flag.Parse()

	if *dbFile == "" {
		log.Fatalf("must provide -db")
	}

	if db, err := model.Initialize(*dbFile); err != nil {
		log.Fatalf("error initializing database: %v", err)
	} else {
		defer db.Close()
	}

	if *templatesDir == "" || *assetsDir == "" {
		log.Fatalf("must provide -assets and -templates")
	}

	static := StaticFileHandler(path.Join(*assetsDir))
	http.Handle("/css/", static)
	http.Handle("/images/", static)
	http.Handle("/js/", static)
	http.Handle("/", NewUI(*templatesDir))
	log.Fatal(http.ListenAndServe(*listenAddr, nil))
}