forked from wegotcoders/wgc_groundwork
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.rb
43 lines (33 loc) · 955 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, 'fb19b1954a924962a6c1625fd3452e7958d2a8df4cab3a320b65221728e43d67'
set :secret, '5ff99ce067ef8dcdafe1d24232af1df3362b2114095dbb2191aae5a1ab8f2ff0'
set :redirect_uri, 'http://localhost:4567/callback'
set :site_url, 'https://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.instance(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