首页 > Web开发 > 详细

nodejs

时间:2015-06-11 12:48:15      阅读:268      评论:0      收藏:0      [点我收藏+]

require方法接受以下几种参数的传递:

    - http、fs、path等,原生模块。
    - ./mod或../mod,相对路径的文件模块。
    - /pathtomodule/mod,绝对路径的文件模块。
    - mod,非原生模块的文件模块。
 
创建服务器http服务器也是调用的一个原生模块-http:
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://127.0.0.1:8888/‘);
启动node

nodejs

原文:http://www.cnblogs.com/pan-hello/p/4568485.html

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