HelloNode

新建HelloNode.js文件,输入:

var http = require("http");
http.createServer(function(request, response){
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("hello node.js");
}).listen(3000);
console.log('http://127.0.0.1:3000/');

保存后,进入命令行窗口,执行:node HelloNode.js

打开浏览器,输入:http://127.0.0.1:3000,如图所示:

posted on 2019-12-28 23:31  渐行渐远的那些人  阅读(124)  评论(0编辑  收藏  举报