-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·34 lines (26 loc) · 923 Bytes
/
index.js
File metadata and controls
executable file
·34 lines (26 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env node
var path = require('path');
var express = require('express');
var contentDisposition = require('content-disposition');
var pkg = require(path.join(__dirname, 'package.json'));
var collect = require('./collect');
var program = require('commander');
program
.version(pkg.version)
.option('-p, --port <port>', 'localhost port to listen on for files (default is 3000)', parseInt)
.parse(process.argv);
var port = program.port || 3000;
var tree = collect('.', 'files');
var app = express();
app.use('/', express.static(path.join(__dirname, 'view')));
app.use('/files', express.static(process.cwd(), {
index: false,
setHeaders: function(res, path){
res.setHeader('Content-Disposition', contentDisposition(path, "inline"))
}
}));
app.get('/collect', function(req,res){
res.send(tree);
});
app.listen(port);
console.log('up and running with your mp3network on ' + port);