Example #1
0
File: main.go Project: andrebq/exp
func main() {
	flag.Parse()

	if *help {
		flag.Usage()
		return
	}
	fs, err := httpfs.NewDiskFile(*dir)
	if err != nil {
		log.Fatalf("error loading root file: %v", err)
	}
	http.Handle("/", &httpfs.Handler{fs})

	log.Printf("starting server at: %v", *addr)

	if err := http.ListenAndServe(*addr, nil); err != nil {
		log.Fatalf("error: %v", err)
	}
}
Example #2
0
File: main.go Project: andrebq/exp
func main() {
	dfs, _ := httpfs.NewDiskFile(".")
	handler := &httpfs.Handler{
		Root: dfs,
	}
	db := &DB{
		DB: mustOpenShellDb("shell.db"),
	}
	http.Handle("/fs/", http.StripPrefix("/fs/", handler))
	http.Handle("/db/", http.StripPrefix("/db/", db))
	http.Handle("/", &ServeStaticFiles{
		staticServer: http.FileServer(http.Dir(filepath.FromSlash("./static"))),
	})

	go cleanup(db)

	if err := http.ListenAndServe("localhost:4001", nil); err != nil {
		log.Printf("Error starting server: %v", err)
	}
}