nodejs初步搭建HelloWord

Posted 月疯

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nodejs初步搭建HelloWord相关的知识,希望对你有一定的参考价值。

开发环境:下载安装nodejs

win10系统,webstrom开发工具

hello.js

//导入http
var http=require('http');

//创建
http.createServer(function (request,response) {
    response.writeHead(200,{'Content-type':'text/html;charset=utf-8'});
    if(request.url!=='/favicon.ico'){//清除二次访问
        console.log('访问');
        response.write('hello world');
        response.end("世界");//不写会没有协议尾部,但是写了会访问俩次
    }
}).listen(8000);
console.log('Server running at http://127.0.0.11:8000/')

 

 

 

以上是关于nodejs初步搭建HelloWord的主要内容,如果未能解决你的问题,请参考以下文章