美文网首页
node中http模块

node中http模块

作者: 夏夏夏夏顿天 | 来源:发表于2018-10-15 11:14 被阅读6次

http是构建http服务器重要的模块

如何构建http服务器

const http = require('http')

const server = http.createServer((req, res) => {
    console.log(req)
    console.log(res)
    res.end('2222222222')
})

server.listen(3000)


这么简单的几行代码就可以,在浏览器访问localhost:3000, 看到效果

其实很重要的,还是http模块中的request,response,请求数据,和响应数据,进行获取和设置

request

请求,说几个比较常见的,方法和属性

相关文章

  • node中http模块

    http是构建http服务器重要的模块 如何构建http服务器 这么简单的几行代码就可以,在浏览器访问localh...

  • HTTP模块

    Node的HTTP模块包含对http处理的封装。在node中,HTTP服务继承自TCP服务器(net模块),它能够...

  • 兄弟会8.9号笔记

    node.js模块学习 http 模块 fs 模块 url 模块 http 模块 HTTP http.STA...

  • Node.js HTTP模块

    内置HTTP模块 Node.js 中有 HTTP 这个内置模块,HTTP 模块允许 Node.js 通过超文本传输...

  • Node.js 之 http模块

    http模块 引入http模块 开启一个本地服务器需要Node.js中http核心模块http--模块提供了搭建本...

  • Nodejs的模块引入与回调函数

    Node.js模块系统 在 Node.js 中,引入一个模块 如: var http=require('fs');...

  • node中的核心模块

    node的模块有很多,但常用的只有几个核心模块,例如fs文件系统模块,path模块,http模块等。node中的J...

  • Node.js HTTP服务器

    Node.js HTTP服务器 安装http-server模块: 命令中的-g参数会把http-server 模块...

  • Node中的HTTP模块

    Node就是用javascript语言搭建服务器。node官方提供了很多模块供我们使用,其中http就是其中的一种...

  • node模块载入机制

    node内模块以及载入顺序为: 内置模块 文件模块 文件目录模块 node_modules模块 内置模块 http...

网友评论

      本文标题:node中http模块

      本文链接:https://www.haomeiwen.com/subject/smaxzftx.html