Skip to content

Commit 19679b7

Browse files
committed
added rest of routes
1 parent 2877572 commit 19679b7

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ GET http://api.spacexdata.com/launches/2017
4343

4444
Get 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

app.rb

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
#end
3333

3434
# Uses subdomain api.exaample.com to route traffic
35-
subdomain :api do
35+
#subdomain :api do
3636

3737
get '/' do
38-
results = DB.query("SELECT * FROM launches")
39-
results.count
38+
content_type :json
39+
JSON.pretty_generate($home_info)
4040
end
4141

4242
get '/info' do
@@ -63,4 +63,31 @@
6363
content_type :json
6464
JSON.pretty_generate($sites)
6565
end
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)
6692
end
93+
#end

0 commit comments

Comments
 (0)