static.js 613 B

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