NodeJS简单实例

   ******前提确保你的NodeJs已经安装成功。

        1.      我在 D:/NEW PROJECT/NodeJs/2017-12-29  文件夹下创建了demo.js  放入一下面代码:

var http = require("http");

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

        2.   win+R,调出cmd,回车进入。

                   1) 输入 上面路径      CD D:/NEW PROJECT/NodeJs/2017-12-29    回车        

                   2) 再输入 d:  回车   

          

                 3)最后输入 node demo.js

            

 

          4) 浏览器输入地址    http://127.0.0.1:3002/

          

 

 

 

 

 

            

           

            

          

                 

posted @ 2017-12-29 16:18  取个好名字呢  阅读(216)  评论(0)    收藏  举报