首页 > 编程语言 >Node向后端发送请求响应请求

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

时间:2023-03-15 23:45:07浏览次数:34  
标签:Node node http 请求 js 发送 response

//导入模块(请求是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/')

  

标签:Node,node,http,请求,js,发送,response
From: https://www.cnblogs.com/wsx123/p/17220702.html

相关文章