前端歌谣-第伍拾贰课-node之http模块之zlib模块

64 阅读1分钟

前言

我是歌谣 微信公众号关注前端小歌谣一起学习前端知识 今天继续给大家讲解node中zlib模块的讲解

案例

const http=require("http")
const fs=require("fs")
http.createServer((req,res)=>{
   const reads=fs.createReadStream("./index.js")
   res.writeHead(200,{"Content-type":"applocation/x-javascript;charset=utf-8"})
   reads.pipe(res)
}).listen(3000,()=>{
    console.log("geyao")
})

运行结果

在这里插入图片描述