forked from wegotcoders/wgc_groundwork
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.rb~
43 lines (33 loc) · 838 Bytes
/
app.rb~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require 'sinatra'
require './lib/profile'
set :application_id, 'EDIT_ME'
set :secret, 'EDIT_ME'
set :redirect_uri, 'http://localhost:4567/callback'
set :site_url, 'http://wegotcoders.com'
set :session_secret, 'secret'
enable :sessions
get '/primes' do
# TODO - Can we make this dynamic?
limit = 100
# TODO - add your prime number solution in the primes.rb file.
@sum = Primes.sum_to(limit)
erb :primes, :layout => :main
end
get '/' do
if signed_in?
@profile = trainee.get_profile
end
erb :index, :layout => :main
end
post '/update' do
response = trainee.update_profile(params)
if @errors = response["errors"]
erb :error, :layout => :main
else
redirect '/'
end
end
include Sinatra::OauthRoutes
def trainee
@trainee ||= WeGotCoders::Trainee.new(settings.site_url, session[:access_token])
end