[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