From 8b172fccb27175fc381e6759e56c4b2f704f48b4 Mon Sep 17 00:00:00 2001 From: andy-aguilar Date: Wed, 6 Jan 2021 11:18:21 -0600 Subject: [PATCH] Done. --- first.ru | 9 +++++++++ my_server.rb | 9 +++++++++ second.ru | 11 +++++++++++ third.ru | 2 ++ 4 files changed, 31 insertions(+) create mode 100644 first.ru create mode 100644 my_server.rb create mode 100644 second.ru create mode 100644 third.ru diff --git a/first.ru b/first.ru new file mode 100644 index 00000000..09e559a0 --- /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 World!']] +end + +run my_server \ No newline at end of file diff --git a/my_server.rb b/my_server.rb new file mode 100644 index 00000000..38cdd57f --- /dev/null +++ b/my_server.rb @@ -0,0 +1,9 @@ +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..cf251f9e --- /dev/null +++ b/second.ru @@ -0,0 +1,11 @@ +class MyServer + def call(env) + return [ 200, {'Content-Type' => 'text/html'}, pretty_response ] + end + + def pretty_response + (Time.now.to_i % 2).zero? ? ["#{Time.now} - Hello"] : ["#{Time.now.to_i} - 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