基本的node.js代码不工作
服务器正在启动,没有任何错误,但url被击中,显示没有应用程序运行。
url: link_To_Server
我的代码:
var express= require('express'); var app=express(); app.get('/', function(req, res, next) { console.log('home'); res.send(200); res.end('getting requests'); }); console.log('server started');
您实际上并没有设置服务器来侦听端口。 更换
console.log('server started');
同
app.listen(3000, function() { console.log('server started'); });
请注意,对于上面的示例,绑定的端口是3000.有关更多信息,请参阅API文档