首页 > Windows开发 > 详细

Nodejs v4.4.0API文档学习(1)简介

时间:2016-03-14 18:25:24      阅读:300      评论:0      收藏:0      [点我收藏+]

文档参考地址:https://nodejs.org/dist/latest-v4.x/docs/api/

简介

下面是用nodejs编写的一个web服务的例子,返回"Hello World"。

const http = require(‘http‘);

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

console.log(‘Server running at http://127.0.0.1:8124/‘);

来运行这个服务,先把上面的代码保存在一个命名为example.js的文件中,然后使用node程序执行

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

文档中所有的例子都能同样的方式去执行。

  


Nodejs v4.4.0API文档学习(1)简介

原文:http://www.cnblogs.com/fhen/p/5276550.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!