【问题标题】:Confused in the Hello World example, the Node.JS way在 Hello World 示例中感到困惑,Node.JS 方式
【发布时间】:2014-05-12 08:32:48
【问题描述】:

这是大多数 Node.JS 书籍中给出的典型 hello world 示例 -

var http = require('http');
    http.createServer(function (req, res) {
    res.**writeHead**(200, {'Content-Type': 'text/plain'});
    res.**end**('Hello World\n');
    }).listen(8124, "127.0.0.1");

我可以理解,通过“require” html 功能已被放入 var http。 因此 .createserver 函数将被写入该模块中,作为回调的参数,我们将向该模块传递一个匿名函数。 但是“写头”和“结束”在哪里定义?它到底是什么?

【问题讨论】:

    标签: node.js


    【解决方案1】:

    res 是类 ServerResponse http://nodejs.org/api/http.html#http_class_http_serverresponse 的一个实例

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-13
      • 2012-04-04
      • 2012-07-03
      • 1970-01-01
      相关资源
      最近更新 更多