Commits

rgrau  committed 3668b4b

basic functionality working

  • Participants
  • Parent commits 7dd1b23

Comments (0)

Files changed (5)

+source 'https://rubygems.org'
+ruby '2.0.0'
+
+gem 'newrelic_rpm'
+gem 'sinatra'
+gem 'thin'
+gem 'shotgun'
+gem 'json'
+gem 'httpclient'
+gem 'pry'

File Gemfile.lock

+GEM
+  remote: https://rubygems.org/
+  specs:
+    coderay (1.0.9)
+    daemons (1.1.9)
+    eventmachine (1.0.3)
+    httpclient (2.3.4.1)
+    json (1.8.1)
+    method_source (0.8.2)
+    newrelic_rpm (3.6.8.168)
+    pry (0.9.12.2)
+      coderay (~> 1.0.5)
+      method_source (~> 0.8)
+      slop (~> 3.4)
+    rack (1.5.2)
+    rack-protection (1.5.0)
+      rack
+    shotgun (0.9)
+      rack (>= 1.0)
+    sinatra (1.4.3)
+      rack (~> 1.4)
+      rack-protection (~> 1.4)
+      tilt (~> 1.3, >= 1.3.4)
+    slop (3.4.6)
+    thin (1.6.0)
+      daemons (>= 1.0.9)
+      eventmachine (>= 1.0.0)
+      rack (>= 1.5.0)
+    tilt (1.4.1)
+
+PLATFORMS
+  ruby
+
+DEPENDENCIES
+  httpclient
+  json
+  newrelic_rpm
+  pry
+  shotgun
+  sinatra
+  thin

File celebritystatus.rb

+#shotgun app.rb -p 9294
+require 'sinatra'
+require "json"
+require 'httpclient'
+require 'pry'
+
+def is_dead(name)
+  json = HTTPClient.get("http://en.wikipedia.org/w/api.php?action=query&titles=#{name}&prop=revisions&rvprop=content&format=json&rvsection=0")
+  lines = json.body.split("\\n")
+  is_dead = lines.grep(/death_date/)
+  if is_dead.size > 0
+    return true
+  else
+    return false
+  end
+end
+
+get '/is_dead' do
+  puts request.query_string
+  name = params[:name]
+  {name: params[:name],
+   is_dead: is_dead(name)}.to_json
+end
+require './celebritystatus'
+run Sinatra::Application
-Creating celebritystatus-backend... done, stack is cedar
-http://celebritystatus-backend.herokuapp.com/ | git@heroku.com:celebritystatus-backend.git
+
+* Repo
+  Creating celebritystatus-backend... done, stack is cedar
+  http://celebritystatus-backend.herokuapp.com/ | git@heroku.com:celebritystatus-backend.git
+
+* Endpoints
+  http://celebritystatus-backend.herokuapp.com/is_dead?name=Michael_Jackson
+  Beware, the name has to be the exact name on wikipedia's page. that
+  makes it a bit unstable for the moment.