static.js 552 B

123456789101112131415161718192021222324
  1. var static = require('node-static');
  2. var server = new static.Server('.', {cache: 0});
  3. require('http').createServer(function(req, res) {
  4. if (req.url === '/favicon.ico') {
  5. req.destroy();
  6. res.statusCode = 204;
  7. return res.end();
  8. }
  9. req.on('end', function() {
  10. server.serve(req, res, function(err) {
  11. if (err) {
  12. console.error(err, req.url);
  13. res.writeHead(err.status, err.headers);
  14. res.end();
  15. }
  16. });
  17. });
  18. req.resume();
  19. }).listen(8088);
  20. console.error('now listening on http://localhost:8088');