From ce388a75523cce88f97d6a1b20f3fd5635100896 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Sat, 16 Feb 2019 23:09:42 +0000 Subject: Formatted endpoint --- scarecrow.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'scarecrow.rb') diff --git a/scarecrow.rb b/scarecrow.rb index b4fadf9..defc135 100644 --- a/scarecrow.rb +++ b/scarecrow.rb @@ -66,7 +66,14 @@ def handle_temp_message(msg) end get '/' do - send_file File.join(settings.public_folder, 'index.html') + # send_file File.join(settings.public_folder, 'index.html') + 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}" end get '/temperature' do @@ -75,8 +82,8 @@ get '/temperature' do end get '/humidity' do - temp = Humidity.last[:value] - "#{temp}" + humidity = Humidity.last[:value] + "#{humidity}" end init -- cgit v1.2.3