http.createServer(function(req, res){ if (gun.wsp.server(req, res)) { return; // filters gun requests! } fs.createReadStream(path.join(__dirname, req.url)) .on('error', function() { // static files! res.writeHead(200, {'Content-Type': 'text/html'}); res.end(fs.readFileSync(path.join(__dirname, 'index.html'))); // or default to index }).pipe(res); // stream })