开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜