[英]basic node.js code not working
Server is starting without any errors but the URL is hit its showing no application running. 服务器正在启动,没有任何错误,但是URL被打中,表明没有应用程序在运行。
URL: link_To_Server 网址: link_To_Server
My Code: 我的代码:
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');
You didn't actually set the server to listen to a port. 您实际上没有将服务器设置为侦听端口。 Replace
更换
console.log('server started');
With 用
app.listen(3000, function() {
console.log('server started');
});
Note that with the above example, the bound port is 3000. For more info, see the API doc 请注意,在上面的示例中,绑定端口为3000。有关更多信息,请参见API文档
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.