Created
February 24, 2011 20:53
-
-
Save niklasfi/842860 to your computer and use it in GitHub Desktop.
fast
This file contains hidden or 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'), | |
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