NodeJs创世纪

到NodeJS官网下载安装稳定版。
选择一款IDE,我选用的是Webstorm
app.js:

var http = require('http');
http.createServer(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write('<h1>Node.js</h1>');
res.end('<p>Hello World</p>');
}).listen(3000);
console.log("HTTP server is listening at port 3000.");

在命令行中键入node app.js
访问http://127.0.0.1:3000
顺利的话会在浏览器中显示如下内容:
hello.png

Last modification:September 27th, 2018 at 09:33 am
If you think my article is useful to you, please feel free to appreciate

Leave a Comment