nodejs--hello word

    开始一个简单的程序,hello world:

var http = require("http");

http.createServer(function(request, response) {
    response.writeHead(200, {"Content-Type" : 'text/plain'});
    response.end("Hello world\n");
}).listen(8888);

console.log("Server running at http://localhost:8888");

   保存为hello_world.js,使用node执行一下该文件。

$ node hello_word.js
Server running at http://localhost:8888

   在浏览器输入http://localhost:8888请求,页面输出:

Hello world

  

 

posted on 2016-03-17 23:32  可乐不加冰Litb  阅读(165)  评论(0)    收藏  举报