File tree Expand file tree Collapse file tree 2 files changed +31
-4
lines changed Expand file tree Collapse file tree 2 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ GET http://api.spacexdata.com/launches/2017
4343
4444Get launches in a date range
4545``` http
46- GET http://api.spacexdata.com/launches/from=01-20-2011 /to=01-20-2017
46+ GET http://api.spacexdata.com/launches/from=2011- 01-20/to=2017-05-25
4747```
4848<br ></br >
4949
Original file line number Diff line number Diff line change 3232#end
3333
3434# Uses subdomain api.exaample.com to route traffic
35- subdomain :api do
35+ # subdomain :api do
3636
3737get '/' do
38- results = DB . query ( "SELECT * FROM launches" )
39- results . count
38+ content_type :json
39+ JSON . pretty_generate ( $home_info )
4040end
4141
4242get '/info' do
6363 content_type :json
6464 JSON . pretty_generate ( $sites)
6565end
66+
67+ get '/launches' do
68+ content_type :json
69+ results = DB . query ( "SELECT * FROM launches" )
70+ hash = results . each do |row |
71+ end
72+ JSON . pretty_generate ( hash )
73+ end
74+
75+ get '/launches/:year' do
76+ content_type :json
77+ year = params [ 'year' ]
78+ results = DB . query ( "SELECT * FROM launches WHERE launch_year = #{ year } " )
79+ hash = results . each do |row |
80+ end
81+ JSON . pretty_generate ( hash )
82+ end
83+
84+ get '/launches/from=:start/to=:final' do
85+ content_type :json
86+ start = params [ 'start' ]
87+ final = params [ 'final' ]
88+ results = DB . query ( "SELECT * FROM launches BETWEEN #{ start } AND #{ final } " )
89+ hash = results . each do |row |
90+ end
91+ JSON . pretty_generate ( hash )
6692end
93+ #end
You can’t perform that action at this time.
0 commit comments