gpt4 book ai didi

javascript - 意外的 : HTTP request handler function called twice for each request

转载 作者:行者123 更新时间:2023-11-28 05:53:03 26 4
gpt4 key购买 nike

var http = require('http');
http.createServer(function (req, res) {
///console.log(req);
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
console.log("Inside the handler function");
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');

为什么上面的 Node.js 代码打印了两次 console.log("Inside ...") 消息?我希望当服务器收到来自客户端(浏览器)的一个请求时它会打印一次。

谢谢。

最佳答案

Chrome 对网站图标提出了额外请求。Mozilla 和 Safari 不..

关于javascript - 意外的 : HTTP request handler function called twice for each request,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37935979/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com