From e1bfe738a33c84cf3470a1e15e38a79a60a12e2b Mon Sep 17 00:00:00 2001 From: github username Date: Wed, 10 Mar 2021 16:59:16 -0500 Subject: [PATCH] Done. --- first.ru | 9 +++++++++ second.ru | 14 ++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 first.ru create mode 100644 second.ru diff --git a/first.ru b/first.ru new file mode 100644 index 00000000..27a87ff1 --- /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']] +end + +run my_server \ No newline at end of file diff --git a/second.ru b/second.ru new file mode 100644 index 00000000..6330554a --- /dev/null +++ b/second.ru @@ -0,0 +1,14 @@ +require 'rack' + +# Something that responds to call, that's what Rack demands +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