nodejs学习笔记一

1、创建一个http web服务器,并返回Hello World!

复制代码
const http = require('http');

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

console.log('Server running at http://127.0.0.1:8888/');
复制代码

2、启动服务器,在浏览器中输入http://127.0.0.1:8888/,页面显示Hello World。

$ node example.js
Server running at http://127.0.0.1:8888/

 

posted @ 2016-02-19 14:42  halapro.liu  阅读(140)  评论(0编辑  收藏  举报