al-quran.reflectslight.io/packages/ruby/server/README.md
Robert bf1558eeb0
Add packages/ruby/server/ (#132)
### Summary

The `server` package implements a static file web server intended to be 
used during development. The goal is to have it as close to a production
environment as possible. Not there yet. This is the first step.
2023-06-25 21:03:07 -03:00

890 B

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.