[node] app.listen()问题

楼主: luckid (luckid)   2015-12-17 13:45:20
各位前辈好,
http://expressjs.com/en/starter/hello-world.html
expressjs.com上面有一个简单的hello world范例,
其中末尾的程式码如下:
var server = app.listen(3000, function () {
var host = server.address().address;
var port = server.address().port;
console.log('Example app listening at http://%s:%s', host, port);
若是按照此范例去跑,
console会出现如下讯息:
Example app listening at http://:::3000
但我在想是否可修改该范例的末尾写法,
让console可以出现(假设在本机上跑):
Example app listening at http://localhost:3000
还望前辈不吝指点迷津,感谢.

Links booklink

Contact Us: admin [ a t ] ucptt.com