Node向后端发送请求响应请求

//导入模块(请求是http)
//Node.js
//理解:Node.js和jdk差不多是一样的道理,是基于coogle的v8引擎
//在控制台进行打印 node运行方式:node 文件名称 node Hello.js
const http = require('http');
//创建http服务
http.createServer(function(requery,response){
    //发送请求后,接受响应:第一个状态码
    response.writeHead(200,{'Content-type':'text/plain'});
    //将对应数据响应到页面上
    response.end("<p>hello server!!!</p>");
    //设置端口
}).listen(8888);
console.log('服务起来了,访问网址:http://localhost:8888/')

  

posted on 2023-03-15 23:36  爱前端的小魏  阅读(49)  评论(0编辑  收藏  举报

导航