From b1391deafa2f12aeac771c46788e152b0c0ea9b5 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Sun, 17 Feb 2019 02:26:06 +0000 Subject: Add template --- scarecrow.rb | 10 +++++----- views/index.erb | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 views/index.erb diff --git a/scarecrow.rb b/scarecrow.rb index defc135..b1043fe 100644 --- a/scarecrow.rb +++ b/scarecrow.rb @@ -67,13 +67,13 @@ end get '/' do # send_file File.join(settings.public_folder, 'index.html') - temp_val = Temperature.last[:value] - humidity_val = Humidity.last[:value] + @temp_val = Temperature.last[:value] + @humidity_val = Humidity.last[:value] temp_time = Temperature.last[:timestamp] humidity_time = Humidity.last[:timestamp] - time_formatted = temp_time.strftime("%A, %d %b %Y %l:%M %p") - - return "#{temp_val}°C and #{humidity_val}% humidity at #{time_formatted}" + @time_formatted = temp_time.strftime("%A, %d %b %Y %l:%M %p") + erb :index + # return "#{temp_val}°C and #{humidity_val}% humidity at #{time_formatted}" end get '/temperature' do diff --git a/views/index.erb b/views/index.erb new file mode 100644 index 0000000..8449835 --- /dev/null +++ b/views/index.erb @@ -0,0 +1,15 @@ + + + + The Scarecrow Watches Over The Garden + + + +

thebluegarden

+ +

<%= @temp_val %>°C and <%= @humidity_val %>% humidity at <%= @time_formatted %>

+

+ +

+ + -- cgit v1.2.3