-
Notifications
You must be signed in to change notification settings - Fork 6
/
app.rb
44 lines (36 loc) · 788 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/bookmark'
class Bookmark_Manager < Sinatra::Base
enable :sessions, :method_override
get '/' do
erb :index
end
get '/bookmarks' do
@bookmarks = Bookmark.all
erb :bookmarks
end
post '/add_bookmarks' do
@bookmarks = Bookmark.all
url = params['url']
name = params['name']
Bookmark.create(url,name)
redirect '/bookmarks'
end
get '/add_bookmarks' do
@bookmarks = Bookmark.all
erb :add_bookmarks
end
get '/delete_bookmarks' do
@bookmarks = Bookmark.all
erb :delete
end
delete '/bookmarks/' do
p params
p "are we before the delete?"
id = params[:id]
Bookmark.delete(id)
p "are we getting here?"
redirect '/bookmarks'
end
run! if app_file == $0
end