5 ms·
Instead of reading in static files yourself, you can just use connect (or s/connect/express/g and it'll also work): var connect = require('connect'); v
by substack 16y ago
Instead of reading in static files yourself, you can just use connect (or s/connect/express/g and it'll also work):
var connect = require('connect');
var server = connect.createServer(connect.staticProvider(__dirname + '/static')).listen(4000);
Pow, that was easy! Plus, since connect (and express) are just up the prototype chain from http.Server, it works great with socket.io.
- DTrejo 16y agoanother option is cloudhead's node-static: https://github.com/cloudhead/node-static https://github.com/cloudhead/node-static