【发布时间】:2016-04-29 02:31:42
【问题描述】:
我尝试在 Node.js 中创建自己的“服务器”并将其连接到我的 WAMP 端口 8888。 但不知何故,我没有得到任何回复,不是 localhost:8888 页面上的响应,甚至不是 console.log?
当我使用不同的端口时,甚至没有任何反应......
var http = require('http');
function onRequest(request, response){
console.log("A user made a request" + request.url);
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Here is some data");
response.end();
}
http.createServer(onRequest).listen(8888);
console.log("Server is now running...");
有人可以帮我走正确的路吗?
问候 延斯
【问题讨论】:
-
你的 wamp 服务器是如何配置的?它在哪个端口上侦听?它是如何连接到你的 node.js 服务器的?
-
正在监听 80 端口
标签: node.js apache http server wamp