Skip to content

Instantly share code, notes, and snippets.

View KJlmfe's full-sized avatar

KJlmfe KJlmfe

  • China
View GitHub Profile
@KJlmfe
KJlmfe / async_node.js
Last active August 2, 2016 06:29
Node异步执行
var fs = require('fs');
//异步读取Hello.txt
fs.readFile('Hello.txt','utf-8',
//回调函数里输出Hello.txt里的内容
function(err, data){
console.log(data);
}
);
@KJlmfe
KJlmfe / node_use_module_example.js
Last active August 2, 2016 06:29
Node内置核心模块与第三方模块使用举例
var http = require('http'); //导入内置模块http
//调用内置模块http提供的createServer的API
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');