kemal/src/kemal.cr

22 lines
551 B
Crystal
Raw Normal View History

2014-06-11 23:41:02 +00:00
require "option_parser"
2015-10-23 19:48:30 +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
2015-11-12 20:48:22 +00:00
config.add_handler HTTP::LogHandler.new
config.add_handler Kemal::Handler::INSTANCE
config.add_handler HTTP::StaticFileHandler.new("./public")
server = HTTP::Server.new(config.port, config.handlers)
2014-07-30 22:17:53 +00:00
server.ssl = config.ssl
2014-06-11 23:41:02 +00:00
2015-11-08 15:43:53 +00:00
puts "Kemal is ready to lead at #{config.scheme}://0.0.0.0:#{config.port}"
2014-06-11 23:41:02 +00:00
server.listen
end