/Gemfile
/Procfile
1 | web: bundle exec ruby app.rb -p $PORT |
1 | web: bundle exec rackup config.ru -p $PORT |
01 | require 'rubygems' |
02 | require 'sinatra' |
03 | require 'json' |
04 |
05 | get "/app" do |
06 | json_data = open( "settings/shuzo.json" ) do |io| |
07 | JSON.load(io) |
08 | end |
09 | json_data[ "items" ]. each do | item | |
10 | content_type :json |
11 | if params[ "id" ] == item[ "id" ] |
12 | body << item.to_json |
13 | end |
14 | end |
15 | body |
16 | end |
01 | { |
02 | "items" :[{ |
03 | "id" : "1" , |
04 | "name" : "Kuwako" , |
05 | "age" : "29" |
06 | },{ |
07 | "id" : "2" , |
08 | "name" : "Matsuoka" , |
09 | "age" : "48" |
10 | }] |
11 | } |
0 件のコメント:
コメントを投稿