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 sys = require('sys'), | |
spawn = require('child_process').spawn, | |
http = require('http'); | |
http.createServer(function (request, response) { | |
response.writeHead(200, {'Content-Type': 'text/plain'}); | |
var tail = spawn('tail', ['-f', '/var/log/system.log']); | |
var kill_tail = function() { | |
tail.kill(); |
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 sys = require('sys'), | |
spawn = require('child_process').spawn, | |
http = require('http'); | |
http.createServer(function (request, response) { | |
response.writeHead(200, {'Content-Type': 'text/plain'}); | |
var cat = spawn('tail', ['-f', '/var/log/system.log']); | |
cat.stdout.on('data', function(data) { | |
response.write(data); | |
}); |
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
fs.open('/etc/passwd', 'r', 0666, function(err, fd) { | |
http = require('http'); | |
http.createClient(80, 'www.myserver.net'); | |
// ... | |
}); |
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 Step = require('step'); | |
Step( | |
function readSelf() { | |
fs.readFile(__filename, this); | |
}, | |
function capitalize(err, text) { | |
if (err) { | |
throw err; | |
} |
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 filename = "log.txt"; | |
(function(filename) { | |
fs.open(filename, 'r', 0666, function(err, fd) { | |
sys.log('opened file '+filename); | |
}); | |
})(filename); | |
filename = "/etc/passwd"; |
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 fs = require('fs'); | |
var sys = require('sys'); | |
var filename = 'test.mov'; | |
var content_type = 'video/quicktime'; | |
http.createServer(function (request, response) { | |
response.writeHead(200, { | |
'Content-Type': content_type |
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
fs.readFile('/etc/passwd', function (err, data) { | |
if (err) throw err; | |
console.log(data); | |
}); |
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 net = require('net'); | |
net.createServer(function (socket) { | |
socket.setEncoding("utf8"); | |
socket.write("Echo server\r\n"); | |
socket.on("data", function (data) { | |
socket.write(data); | |
}); | |
socket.on("end", function () { | |
socket.end(); | |
}); |
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'); | |
http.createServer(function (req, res) { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end('Hello World\n'); | |
}).listen(8124, "127.0.0.1"); | |
console.log('Server running at http://127.0.0.1:8124/'); |
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 sys = require( 'sys' ); | |
var http = require('http'); | |
var form_doc = '\ | |
<html> \ | |
<body>\ | |
<form method="POST" action="/body">\ | |
<input type="submit" name="test" value="Body" />\ | |
</form>\ | |
<form method="POST" action="/nobody">\ |