1 2 3 4 5 6 7 8 9 10 11 12 13
require 'sinatra' require './gpio' gpio = Gpio.new(1) get '/' do "Lightswitch <form method='POST' action='/'><input type='submit' value='#{gpio.value ? 'Off' : 'On'}'></form>" end post '/' do gpio.toggle redirect '/' end