Created
January 5, 2016 17:04
-
-
Save JustinBeckwith/928af8de7cac7538e7c5 to your computer and use it in GitHub Desktop.
deasync sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "inittest", | |
"version": "1.0.0", | |
"description": "", | |
"main": "server.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
"start": "node server.js" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"deasync": "^0.1.4" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var deasync = require('deasync'); | |
var cp = require('child_process'); | |
var exec = deasync(cp.exec); | |
console.log('done'); | |
var server = http.createServer(function (request, response) { | |
response.writeHead(200, {"Content-Type": "text/plain"}); | |
try{ | |
response.write(exec('ls -la')); | |
} | |
catch(err){ | |
console.log(err); | |
} | |
response.end("Hello World\n"); | |
}); | |
server.listen(8080); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment