何か:
var fs = require('fs'),
http = require('http'),
path = require('path');
http.createServer(function(req,res){
path.exists('./' + req.url, function(exists){
if (!exists){ res.writeHead(404, {'Content-Type': 'text/plain'}); res.end('not found'); }
else {
var read_stream = fs.createReadStream('./' + req.url);
if (read_stream.readable){ res.writeHead(200, {'Content-Type':'text/plain'}); }
else { res.writeHead(500, {'Content-Type':'text/plain'}); res.end('Error Reading File'); }
read_stream.on('data', function(data){ res.write(data); });
read_stream.on('end', function(){ res.end(); fs.close(read_stream); });
}
}
}).listen(3030);
ここでの主なトリックが読めるストリームを使用することですファイルの JavaScriptの:アプリケーション/ javascriptの HTML:text/htmlの CSS:テキスト/ cssの JPEG:画像/ JPEG GIF:画像/ gif形式
HTTPサーバは、次のコンテンツの種類(HTTPレスポンスヘッダ)をサポートする必要があります – user1066986