説明なし

static.coffee 688B

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