Base server, no parsing of dbus-send output.
This commit is contained in:
commit
78a6c49198
2 changed files with 36 additions and 0 deletions
3
README.md
Normal file
3
README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
Launch the server and punch this in your browser:
|
||||
|
||||
http://localhost:3000/status/current_downloads
|
33
ubuntuone.js
Normal file
33
ubuntuone.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
var http = require('http'),
|
||||
exec = require('child_process').exec,
|
||||
pieces, interface, method, dbus_send, child;
|
||||
|
||||
http.createServer(function(request, response)
|
||||
{
|
||||
pieces = request.url.split('/');
|
||||
|
||||
response.writeHead(200, {'Content-Type': 'text/plain'});
|
||||
|
||||
if (pieces.length == 3)
|
||||
{
|
||||
interface = pieces[1].toLowerCase();
|
||||
method = pieces[2].toLowerCase();
|
||||
|
||||
dbus_send = 'dbus-send --session --print-reply --type=method_call'
|
||||
+ ' --dest=com.ubuntuone.SyncDaemon /' + interface
|
||||
+ ' com.ubuntuone.SyncDaemon.' + interface.charAt(0).toUpperCase() + interface.slice(1) + '.' + method.toLowerCase();
|
||||
|
||||
child = exec(dbus_send, function(error, stdout, stderr)
|
||||
{
|
||||
if (error !== null)
|
||||
{
|
||||
response.end(stderr);
|
||||
}
|
||||
else
|
||||
{
|
||||
response.end(stdout);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}).listen(3000, "127.0.0.1");
|
Loading…
Add table
Add a link
Reference in a new issue