我是新来的Node.js,我想学习,如果我可以通过写的index.html的URL访问node.js的端口(3000)。我跟着this tutorial创建了一个聊天应用,但我遇到了上面提到的问题。访问本地主机:3000通过本地主机/ myproject的/ index.html的
我希望能够写的本地主机/ myproject的/ index.html的代替本地主机:3000我的浏览器。
我的服务器端JavaScript代码是这样的:
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
app.get('/', function(req, res){
res.sendFile(__dirname + '/index.html');
});
http.listen(3000, function(){
console.log('listening on *:3000');
});
有什么我应该在这里改变?任何帮助,将不胜感激。
为什么你想要使用的应用程序的路由那样会很有趣? –
您使用 –
其Web服务器我使用WAMP其中有Apache服务器 – Thanasis