Class: AmazonStaticSite::Server
- Inherits:
-
Object
- Object
- AmazonStaticSite::Server
- Defined in:
- lib/amazon_static_site/server.rb
Instance Attribute Summary collapse
-
#folder ⇒ Object
readonly
Returns the value of attribute folder.
Instance Method Summary collapse
-
#initialize(folder = ARGV[1] || './public') ⇒ Server
constructor
A new instance of Server.
- #start(host: '0.0.0.0', port: 8080) ⇒ Object
Constructor Details
#initialize(folder = ARGV[1] || './public') ⇒ Server
Returns a new instance of Server.
5 6 7 8 |
# File 'lib/amazon_static_site/server.rb', line 5 def initialize(folder = ARGV[1] || './public') require 'rack' @folder = folder.gsub(/\/$/, '') end |
Instance Attribute Details
#folder ⇒ Object (readonly)
Returns the value of attribute folder.
3 4 5 |
# File 'lib/amazon_static_site/server.rb', line 3 def folder @folder end |
Instance Method Details
#start(host: '0.0.0.0', port: 8080) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/amazon_static_site/server.rb', line 10 def start(host: '0.0.0.0', port: 8080) handler = Rack::Handler::WEBrick app = LocalStaticSite.new app.settings.public_folder = folder puts "Starting server on folder: #{app.settings.public_folder} on http://#{host}:#{port}".green handler.run app, Host: host, Port: port end |