I'm looking to set the listening port within my Rack and Sinatra app, using the PORT environment variable if set otherwise to a default.
I thought I may be able to do something like the following but I'm unsure if this is even the right approach.
class ApplicationController < Sinatra::Base
set :port, ENV['PORT'] || 3000
get '/' do
'Hello, World!'
end
end
This doesn't seem to work, at least not with the rackup
command. What's the correct way to do this?