serve current directory from command line

后端 未结 8 1604
梦如初夏
梦如初夏 2020-12-04 05:15

could someone give me a hint, howto serve the current directory from command line with ruby? it would be great, if i can have some system wide configuration (e.g. mime-types

相关标签:
8条回答
  • 2020-12-04 05:48
    require 'webrick'
    include WEBrick
    
    s = HTTPServer.new(:Port => 9090,  :DocumentRoot => Dir::pwd)
    trap("INT"){ s.shutdown }
    s.start
    
    0 讨论(0)
  • 2020-12-04 05:52

    As Aaron Patterson tweeted it out today you can do:

    ruby -run -e httpd . -p 5000
    

    And you can set the bind address as well by adding -b 127.0.0.1

    Works with Ruby 1.9.2 and greater.

    0 讨论(0)
提交回复
热议问题