Guest User

Untitled

a guest
Jul 19th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #!/usr/bin/env node
  2.  
  3. //Requires `npm install creationix daemon`
  4.  
  5. var cli = require('cli').enable('status', 'daemon');
  6.  
  7. cli.parse({
  8. log: ['l', 'Enable logging'],
  9. port: ['p', 'Listen on this port', 'number', 8080],
  10. serve: [false, 'Serve static files from PATH', 'path', './public']
  11. });
  12.  
  13. cli.main(function (args, options) {
  14. var server, middleware = [];
  15.  
  16. if (options.log) {
  17. this.debug('Enabling logging');
  18. middleware.push(require('creationix/log')());
  19. }
  20.  
  21. this.debug('Serving files from ' + options.serve);
  22. middleware.push(require('creationix/static')('/', options.serve, 'index.html'));
  23.  
  24. server = this.createServer(middleware).listen(options.port);
  25.  
  26. this.ok('Listening on port ' + options.port);
  27. });
Add Comment
Please, Sign In to add comment