我现在正在深入研究node.js的东西,从非常简单的例子开始.
以下代码并不是什么大问题,但已经让我感到困惑:
require('http')
.createServer( function( req, res ) {
console.log( 'receiving request' );
res.end( 'end' );
} )
.listen( 1337, "localhost" );
Run Code Online (Sandbox Code Playgroud)
通过控制台启动服务器之后,我调用了http:// localhost:1337 在控制台中,我得到了"接收请求" - 消息两次,而不是预期的一次.
这是怎么回事?我已经把这容易弄得一团糟了吗?
| 归档时间: |
|
| 查看次数: |
106 次 |
| 最近记录: |