nodejs学习之简单服务器的编写

不废话了!直接上代码:

     1    var http = require('http'); //导入模块http
     2    http.createServer(function(request,response){
     3        response.writeHeader(200,{'Content-Type':'Text/Plain','name':'tom',}); //用来定义响应头部
     4        response.end('Hello World!
'); //用来定义响应主体
     5    }).listen(8888); //监听端口
     6    console.log('mServer is running at http://127.0.0.1:8888...'); //服务器程序的提示信息
原文地址:https://www.cnblogs.com/leomei91/p/7344657.html