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) and simply launch it from every directory.
相关问题
- How to specify memcache server to Rack::Session::M
- Why am I getting a “C compiler cannot create execu
- reference to a method?
- ruby 1.9 wrong file encoding on windows
- gem cleanup shows error: Unable to uninstall bundl
相关文章
- Ruby using wrong version of openssl
- Difference between Thread#run and Thread#wakeup?
- how to call a active record named scope with a str
- “No explicit conversion of Symbol into String” for
- Segmentation fault with ruby 2.0.0p247 leading to
- How to detect if an element exists in Watir
- uninitialized constant Mysql2::Client::SECURE_CONN
- ruby - simplify string multiply concatenation
or if you don't want to use the default port 8000
or if you want to allow connections from localhost only
See the docs.
Use ruby gem Serve.
To install on your system, run
gem install serve
.To serve a directory, simply cd to the directory and run
serve
.Default port is 4000. It can also serve things like ERB, HAML, Slim and SASS.
As Aaron Patterson tweeted it out today you can do:
And you can set the bind address as well by adding
-b 127.0.0.1
Works with Ruby 1.9.2 and greater.
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.
I found it here
Chris
Simplest way possible (thanks Aaron Patterson/n0kada):
Alternate, more complex way:
Even the first command is hard to remember, so I just have this in my
.bashrc
:It serves the current directory on port 3000 by default, but you can also specify the port: