一、创建samp1.js
内容如下:
console.log("Hello World");
运行结果:
PS E:\study\nodejs\demo1> node .\samp1.js Hello World
二、创建第一个应用
创建samp2.js
var http = require("http");
http.createServer(function(require, response){
// 发送Http头部
// HTTP状态值: 200: OK
// 内容类型: text/plain
response.writeHead(200,{'Content-Type': 'text/plain'});
// 发送响应数据
response.end("Hello World\n");
}).listen(8888);
console.log('server runing at http://127.0.0.1:8888/');
运行node .\samp2.js
访问 http://127.0.0.1:8888/

作者:Work Hard Work Smart
出处:http://www.cnblogs.com/linlf03/
欢迎任何形式的转载,未经作者同意,请保留此段声明!
浙公网安备 33010602011771号