【发布时间】:2011-04-23 03:49:51
【问题描述】:
我刚刚使用文档中的这段代码创建了一个 HTTP 服务器:
var sys = require("sys"),
http = require("http");
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello World!");
sys.puts('Connection');
}).listen(8080);
sys.puts("Server running at http://localhost:8080/");**
我的问题是,为什么当我转到 localhost:8080 时,我得到了两次打印的“连接”?这是一个错误吗?
【问题讨论】:
-
看起来是这样,尽管在随后的请求中它会正确打印。第一次访问的东西。
标签: javascript http node.js