Skip to content

Commit

Permalink
Attempted fix for web endpoint #2
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelaossa committed Oct 12, 2014
1 parent 05db3ab commit f367fa7
Showing 1 changed file with 28 additions and 40 deletions.
68 changes: 28 additions & 40 deletions lib/web.rb
Original file line number Diff line number Diff line change
@@ -1,44 +1,32 @@
require 'sinatra'
require 'sinatra/base'
class FitbotWeb

def self.web
@@web
end

def self.start
@@web = Thread.new {

Thread.new {

my_app = Sinatra.new {
set :bind, ENV['IP'] unless ENV['IP'].nil? ##for c9.io support
set :port, ENV['PORT'] unless ENV['PORT'].nil?

##routes
get '/' do
erb :index
end

my_app = Sinatra.new {
set :bind, ENV['IP'] unless ENV['IP'].nil? ##for c9.io support
set :port, ENV['PORT'] unless ENV['PORT'].nil?

##routes
get '/' do
erb :index
end

get '/:name.json' do |name|
Nick.first(:nick => name.downcase).to_json(:only => [:nick, :weight, :height])
end

get '/lifts/:name.json' do |name|
Nick.first(:nick => name.downcase).lifts.to_json(:only => [:lift, :weight, :unit, :reps])
end

get '/lifts/?:name?' do |name|
erb :lifts, :locals => {:name => name}
end
########
}

Thread.current[:web] = my_app

my_app.run!
}
end
get '/:name.json' do |name|
Nick.first(:nick => name.downcase).to_json(:only => [:nick, :weight, :height])
end

get '/lifts/:name.json' do |name|
Nick.first(:nick => name.downcase).lifts.to_json(:only => [:lift, :weight, :unit, :reps])
end

get '/lifts/?:name?' do |name|
erb :lifts, :locals => {:name => name}
end
########
}

Thread.current[:web] = my_app

def self.stop
@@web.exit
end
end
my_app.run!
}

0 comments on commit f367fa7

Please sign in to comment.