具有http.createServer的服务器与在节点js中使用express的服务器之间的区别 [英] Difference between a server with http.createServer and a server using express in node js
问题描述
使用http模块创建服务器和使用节点js中的express框架创建服务器之间有什么区别? 谢谢.
表达框架
express框架在vanilla http模块上方提供了一个抽象层,使处理Web流量和API更加容易.还有大量中间件可用于表达(和表达类似)框架来完成常见任务,例如:CORS,XSRF,POST解析,Cookie等.
http api
http api非常简单,用于设置和管理传入/传出的HTTP连接. Node在这里完成了大部分繁重的工作,但是它确实提供了在大多数节点Web框架中常见的功能,例如: response
对象等.>
What's the difference between creating a server using http module and creating a server using express framework in node js? Thanks.
Ultimately, express uses node's http api behind the scenes.
express framework
The express framework provides an abstraction layer above the vanilla http module to make handling web traffic and APIs a little easier. There's also tons of middleware available for express (and express-like) frameworks to complete common tasks such as: CORS, XSRF, POST parsing, cookies etc.
http api
The http api is very simple and is used to to setup and manage incoming/outgoing ,HTTP connections. Node does most of the heavy lifting here but it does provide things you'll commonly see throughout most node web framework such as: request
/response
objects etc.
这篇关于具有http.createServer的服务器与在节点js中使用express的服务器之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!