-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.rb
44 lines (34 loc) · 857 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
44
require 'sinatra/base'
require './lib/peep'
require './lib/user'
class Chitter < Sinatra::Base
enable :sessions
get '/chitter' do
erb :index
end
get '/chitter/view' do
@peep = Peep.all.reverse
@user = User.all
erb :view
end
post '/chitter' do
Peep.create(user_id: params[:user_id], peep: params[:peep])
session[:user_id] = params[:user_id]
redirect '/chitter'
end
get '/chitter/post' do
erb :post
end
get '/chitter/signup' do
erb :signup
end
post '/chitter/congratulations' do
User.create(email: params[:email], username: params[:username], realname: params[:realname], passwrd: params[:passwrd])
session[:username] = params[:username]
redirect '/chitter/congratulations'
end
get '/chitter/congratulations' do
erb :congratulations
end
run! if app_file == $0
end