diff --git a/first.ru b/first.ru new file mode 100644 index 00000000..2fc65710 --- /dev/null +++ b/first.ru @@ -0,0 +1,9 @@ +require 'rack' + +# Instances of Proc automatically have a call method that runs the block that +# they're initialized with. +my_server = Proc.new do + [200, { 'Content-Type' => 'text/html' }, ['Hello, you are awesome! :)']] +end + +run my_server diff --git a/my_server.rb b/my_server.rb new file mode 100644 index 00000000..595d978d --- /dev/null +++ b/my_server.rb @@ -0,0 +1,11 @@ +require 'rack' + +class MyServer + def call(env) + return [ 200, {'Content-Type' => 'text/html'}, pretty_response ] + end + + def pretty_response + (Time.now.to_i % 2).zero? ? ["Hello"] : ["Hello"] + end +end \ No newline at end of file diff --git a/second.ru b/second.ru new file mode 100644 index 00000000..a30fd374 --- /dev/null +++ b/second.ru @@ -0,0 +1,13 @@ +require 'rack' + +class MyServer + def call(env) + return [ 200, {'Content-Type' => 'text/html'}, pretty_response ] + end + + def pretty_response + (Time.now.to_i % 2).zero? ? ["Hello"] : ["Hello"] + end +end + +run MyServer.new \ No newline at end of file diff --git a/third.ru b/third.ru new file mode 100644 index 00000000..2c9b88b9 --- /dev/null +++ b/third.ru @@ -0,0 +1,2 @@ +require_relative './my_server' +run MyServer.new \ No newline at end of file