require 'bundler/setup'
Bundler.require
require 'sinatra/reloader' if development?
require 'open-uri'
require 'json'
require 'net/http'
get '/' do
erb :form
end
get '/list' do
uri = URI("http://express.heartrails.com/api/json")
uri.query = URI.encode_www_form({
method: "getStations",
x: params[:x],
y: params[:y]
})
res = Net::HTTP.get_response(uri)
json = JSON.parse(res.body)
@stations = json["response"]["station"]
erb :list
end
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>フォーム</title>
</head>
<body>
<table>
<% @stations.each do |station| %>
<tr class="station">
<td class="line"><%= station["line"] %></td>
<td class="name"><%= station["name"] %></td>
</tr>
<% end %>
</table>
</body>
</html>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>フォーム</title>
</head>
<body>
<form action="list" method="get">
<input type="text" name"x" id="x" placeholder="x座標" />
<input type="text" name"y" id="y" placeholder="y座標" />
<input type="submit" value="検索" />
</form>
</body>
</html>
具体的にどこをどうすればいいでしょうか?