Commit 33dc54c1 authored by Giacomo Lavermicocca's avatar Giacomo Lavermicocca

complete functions

parent ecfc52f7
......@@ -5,16 +5,18 @@ const path = require('path');
app.get('/getFiles', getFiles);
var PATH_TORRENTS = '/root/.config/transmission-daemon/torrents/';
function getFiles(request, response) {
var dirTree = ('/root/.config/transmission-daemon/torrents/');
var dirTree = (PATH_TORRENTS);
diretoryTreeToObj(dirTree, function (err, res) {
if (err)
console.error(err);
var list = JSON.stringify(res);
var obj = { "currentDir" : dirTree, "list" : list };
response.send(JSON.stringify(obj));
var json = JSON.stringify(res);
var obj = { "currentDir": dirTree, "res": res };
var str = JSON.parse(JSON.stringify(res));
response.send(obj);
});
}
......@@ -22,7 +24,7 @@ function getFiles(request, response) {
app.get(/^(.+)$/, function (req, res) {
console.log('static file request : ' + req.params);
//res.sendFile(__dirname + req.params[0]);
res.sendFile('/root/.config/transmission-daemon/torrents' + req.params[0]);
res.sendFile(PATH_TORRENTS + req.params[0]);
});
var diretoryTreeToObj = function (dir, done) {
......
Example app listening on port 3000!
static file request : [object Object]
static file request : [object Object]
static file request : [object Object]
static file request : [object Object]
static file request : [object Object]
static file request : [object Object]
static file request : [object Object]
static file request : [object Object]
static file request : [object Object]
static file request : [object Object]
static file request : [object Object]
static file request : [object Object]
static file request : [object Object]
static file request : [object Object]
static file request : [object Object]
static file request : [object Object]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment