Created
November 22, 2014 04:58
-
-
Save schappim/7caeb20e3891cd54e452 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'rubygems' | |
| require 'sinatra' | |
| set :bind, '0.0.0.0' | |
| set :port, 80 | |
| get '/' do | |
| sensor = '28-000005314719' | |
| file_contents = `cat /sys/bus/w1/devices/#{sensor}/w1_slave` | |
| sensor_reading = file_contents.split("=").last.to_f / 1000 | |
| "The temperature is #{sensor_reading} C." | |
| end | |
| get '/camera' do | |
| `raspistill -w 640 -h 480 -t 50 -o ./public/image.jpg` | |
| "<img src='/image.jpg' />" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment