notes
1.StormJs这个是用来干什么的?
2.SIGINT(signal interapt)
3.编译nodejs时,加上 -j 8(表示开启8个make的job?) 编译速度很快
var http = require('http'); // 创建所有目录 var mkdirs = module.exports.mkdirs = function(dirpath, mode, callback) { path.exists(dirpath, function(exists) { if(exists) { callback(dirpath); } else { //尝试创建父目录,然后再创建当前目录 mkdirs(path.dirname(dirpath), mode, function(){ fs.mkdir(dirpath, mode, callback); }); } }); };
7.延迟http 响应
var http = require('http'); http.createServer(function(request, response){ // Write Headers response.writeHead(200);//NOTE HERE // Write Hello World! response.write("Hello World!"); // End Response after 5 seconds setTimeout(function(){ response.end(); }, 5000); }).listen(8000);
上面的代码不能达到先输出 ”Hello World“ 的目的
var http = require('http'); http.createServer(function(request, response){ // Write Headers response.writeHead(200, {'Content-Type': 'text/plain'});//改成这样以后就可以了。为什么呢? // Write Hello World! response.write("Hello World!"); // End Response after 5 seconds setTimeout(function(){ response.end(); }, 5000); }).listen(8000);