al-quran.reflectslight.io/packages/ruby/server
0x1eef b8642cb3f0 Add ability to bind to any host, port
For example:
rake server[0.0.0.0,8888]
2024-03-10 08:53:33 -03:00
..
lib Add ability to bind to any host, port 2024-03-10 08:53:33 -03:00
test server: add gzip support 2023-06-29 12:37:50 -03:00
.gitignore Add packages/ruby/server/ (#132) 2023-06-25 21:03:07 -03:00
.rubocop.yml server: add gzip support 2023-06-29 12:37:50 -03:00
Gemfile Add packages/ruby/server/ (#132) 2023-06-25 21:03:07 -03:00
LICENSE Add packages/ruby/server/ (#132) 2023-06-25 21:03:07 -03:00
README.md Add packages/ruby/server/ (#132) 2023-06-25 21:03:07 -03:00
server.rb.gemspec Add per-env webpack configuration files 2024-02-18 09:26:04 -03:00

About

server.rb implements a static file web server by using the fast performing Ruby web server Puma and a small Rack application.

Examples

Server.for_dir

The Server.for_dir method returns a Server instance that serves the contents of a directory. Server#start spawns a new thread to listen for requests, and afterwards returns the thread. Thread#join can block execution at that point, or execution can continue as normal by not calling Thread#join:

require "server"

##
# Create a Server instance for the contents of a directory
server = Server.for_dir("./build/website/")

##
# Start listening for connections
thr = server.start

##
# Prevent the main thread from exiting
thr.join

License

BSD Zero Clause.
See LICENSE.