static.js 722 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env node
  2. var cli = require('cli').enable('status', 'daemon');
  3. cli.parse({
  4. log: ['l', 'Enable logging'],
  5. port: ['p', 'Listen on this port', 'number', 8080],
  6. serve: [false, 'Serve static files from PATH', 'path', './public']
  7. });
  8. cli.main(function (args, options) {
  9. var server, middleware = [];
  10. if (options.log) {
  11. this.debug('Enabling logging');
  12. middleware.push(require('creationix/log')());
  13. }
  14. this.debug('Serving files from ' + options.serve);
  15. middleware.push(require('creationix/static')('/', options.serve, 'index.html'));
  16. server = this.createServer(middleware).listen(options.port);
  17. this.ok('Listening on port ' + options.port);
  18. });