serve current directory from command line

后端 未结 8 1639
梦如初夏
梦如初夏 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:32

    Web Server in 1 line


    This may or may not be quite what you want but it's so cool that I just had to share it.

    I've used this in the past to serve the file system. Perhaps you could modify it or just accept that it serves everything.

    ruby -rsocket -e 's=TCPServer.new(5**5);loop{_=s.accept;_<<"HTTP/1.0 200 OK\r\n\r\n#{File.read(_.gets.split[1])rescue nil}";_.close}'
    

    I found it here

    Chris

提交回复
热议问题