Election results in the London Borough of Sutton.
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

22 lines
505 B

  1. require 'rubygems'
  2. require 'sinatra'
  3. require 'json'
  4. require 'rest_client'
  5. get '/' do
  6. @wards = %w{ Cheam Sutton Stonecot }
  7. haml :home
  8. end
  9. get '/wards' do
  10. @postcode = params[:postcode].strip.upcase
  11. url = "http://www.uk-postcodes.com/postcode/" + @postcode.gsub(/ /, '') + '.json'
  12. result = RestClient.get(url)
  13. result_ary = JSON.parse(result)
  14. @district_name = result_ary['administrative']['district']['title']
  15. @ward_name = result_ary['administrative']['ward']['title']
  16. haml :wards
  17. end