Skip to content

Commit

Permalink
xchange detail and country codes
Browse files Browse the repository at this point in the history
  • Loading branch information
cmthakur committed Dec 10, 2014
1 parent abe0db9 commit f2d27ec
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*** Get country codes ***
http://localhost:3001/country_codes?ip=github.com
*** Get details ***
http://localhost:3001/details?ip=github.com

*** Get Details ***
*** Get country code ***
http://localhost:3001?ip=github.com
7 changes: 4 additions & 3 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ class App < Sinatra::Base

get '/' do
ip = params['ip']
Tracker.get_details(ip).to_json
Tracker.country_codes(ip)

end

get '/country_codes' do
get '/details' do
ip = params['ip']
Tracker.country_codes(ip)
Tracker.get_details(ip).to_json
end

end
Expand Down
2 changes: 1 addition & 1 deletion lib/tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def self.get_details(ip)

def self.country_codes(ip)
details = geoip.city(ip)
[details[:country_code2], details[:country_code3]]
details[:country_code2] || details[:country_code3]
end


Expand Down

0 comments on commit f2d27ec

Please sign in to comment.