Skip to content

Instantly share code, notes, and snippets.

@kr1sp1n
Forked from mafintosh/index.js
Created July 26, 2016 23:01
Show Gist options
  • Save kr1sp1n/cd935b123c6389d05632c7cce5072fac to your computer and use it in GitHub Desktop.
Save kr1sp1n/cd935b123c6389d05632c7cce5072fac to your computer and use it in GitHub Desktop.
dat stats demo that plays sintel.mp4
var swarm = require('hyperdrive-archive-swarm')
var hyperdrive = require('hyperdrive')
var stats = require('hypercore-stats-ui')
var http = require('http')
var memdb = require('memdb')
var serve = require('hyperdrive-http')
var drive = hyperdrive(memdb())
// a remote dat
var archive = drive.createArchive('2d8186c581cd9c1b4f45e42eb765cebcba983feb8a0525d7bffee1ce3b7a9471')
http.createServer(stats(archive)).listen(10000) // stats ui hosted at http://localhost:10000
http.createServer(serve(archive)).listen(8000) // file hosted at http://localhost:8000/sintel.mp4
swarm(archive)
{
"name": "stats-demo",
"version": "1.0.0",
"description": "dat stats demo",
"main": "index.js",
"dependencies": {
"hypercore-stats-ui": "^1.1.0",
"hyperdrive": "^6.6.0",
"hyperdrive-archive-swarm": "^3.1.0",
"hyperdrive-http": "^3.0.0",
"memdb": "^1.3.1"
},
"devDependencies": {},
"author": "Mathias Buus"
}
# open a terminal
git clone https://gist.github.com/mafintosh/6708a026a88d1e94ee33540eff23f954 stats-demo
cd stats-demo
npm install
node index.js # and go to http://localhost:10000 and http://localhost:8000/sintel.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment