2014-06-11 23:41:02 +00:00
|
|
|
require "option_parser"
|
2015-10-23 18:33:26 +00:00
|
|
|
require "./Kemal/*"
|
2014-06-11 23:41:02 +00:00
|
|
|
|
2014-07-30 22:17:53 +00:00
|
|
|
at_exit do
|
|
|
|
OptionParser.parse! do |opts|
|
|
|
|
opts.on("-p ", "--port ", "port") do |opt_port|
|
2015-10-23 18:33:26 +00:00
|
|
|
Kemal.config.port = opt_port.to_i
|
2014-07-30 22:17:53 +00:00
|
|
|
end
|
2014-06-11 23:41:02 +00:00
|
|
|
end
|
|
|
|
|
2015-10-23 18:33:26 +00:00
|
|
|
config = Kemal.config
|
2014-06-11 23:41:02 +00:00
|
|
|
handlers = [] of HTTP::Handler
|
|
|
|
handlers << HTTP::LogHandler.new
|
2015-10-23 18:33:26 +00:00
|
|
|
handlers << Kemal::Handler::INSTANCE
|
2015-01-31 14:39:50 +00:00
|
|
|
handlers << HTTP::StaticFileHandler.new("./public")
|
2014-07-30 22:17:53 +00:00
|
|
|
server = HTTP::Server.new(config.port, handlers)
|
|
|
|
|
|
|
|
server.ssl = config.ssl
|
2014-06-11 23:41:02 +00:00
|
|
|
|
2014-07-30 22:17:53 +00:00
|
|
|
puts "Listening on #{config.scheme}://0.0.0.0:#{config.port}"
|
2014-06-11 23:41:02 +00:00
|
|
|
server.listen
|
|
|
|
end
|