Skip to content

Instantly share code, notes, and snippets.

@niklasfi
Created February 24, 2011 20:53
Show Gist options
  • Save niklasfi/842860 to your computer and use it in GitHub Desktop.
Save niklasfi/842860 to your computer and use it in GitHub Desktop.
fast
var http = require('http'),
url = require('url'),
fs = require('fs');
http.createServer(function(req,res){
var u = url.parse(req.url);
console.log(u.pathname);
if( u.pathname == '/bigfile' ){
res.writeHead(200);
fs.createReadStream('bigfile').pipe(res);
}
else{
res.writeHead(200,{'Content-Type':'text/plain'});
for(var i = 0; i < 100; i++)
res.write('Hello world\n');
res.end('== THE END ==')
}
}).listen(8888)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment