Giter VIP home page Giter VIP logo

h5ailist's Introduction

About

Package h5ailist is a simple client for retrieving files/directories from a remote h5ai directory list frontend.

Using

package h5ailist_test

import (
	"context"
	"fmt"

	"github.com/kenshaw/h5ailist"
)

func Example() {
	var items []h5ailist.Item
	if err := h5ailist.Walk(context.Background(), "https://larsjung.de/h5ai/demo/file preview", func(n string, item *h5ailist.Item, err error) error {
		switch {
		case err != nil:
			return err
		}
		items = append(items, *item)
		return nil
	}); err != nil {
		panic(err)
	}
	var directories, files int64
	for i, item := range items {
		fmt.Printf("%d: %q\n", i, item.Href)
		if item.IsDir() {
			directories++
		} else {
			files++
		}
	}
	fmt.Printf("items: %d directories: %d files: %d\n", len(items), directories, files)
	// Output:
	// 0: "/h5ai/demo/file%20preview/"
	// 1: "/h5ai/demo/file preview/class_cli.py"
	// 2: "/h5ai/demo/file preview/image-1.jpg"
	// 3: "/h5ai/demo/file preview/image-2.jpg"
	// 4: "/h5ai/demo/file preview/image-3.jpg"
	// 5: "/h5ai/demo/file preview/modulejs-1.14.0.js"
	// 6: "/h5ai/demo/file preview/options.css"
	// 7: "/h5ai/demo/file preview/text.md"
	// items: 8 directories: 1 files: 7
}

h5ailist's People

Contributors

kenshaw avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.