开发者

How does the Express framework or node.js automatically serve javascript files?

开发者 https://www.devze.com 2023-03-15 05:11 出处:网络
I added this line to my index.jade file: script(src=\"/socket.io/socket.io.js\") And somehow it automagically knew how to serve 开发者_Python百科that Javascript file to my client. How does that wor

I added this line to my index.jade file:

script(src="/socket.io/socket.io.js")

And somehow it automagically knew how to serve 开发者_Python百科that Javascript file to my client. How does that work?


Socket.io adds a request handler to the server. See:

https://github.com/learnboost/socket.io/blob/master/lib/manager.js#L90

The handler deals with any requests that begin with /socket.io and handles them (e.g. serving up the socket.io.js file from wherever the module is installed)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号