-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.rb
44 lines (36 loc) · 829 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_relative 'cookbook'
require_relative 'recipe'
require "sinatra"
require "sinatra/reloader" if development?
require "pry-byebug"
require "better_errors"
set :bind, '0.0.0.0'
configure :development do
use BetterErrors::Middleware
BetterErrors.application_root = File.expand_path('..', __FILE__)
end
get '/' do
@cookbook = Cookbook.new('recipes.csv').all
erb :index
end
get '/new' do
erb :new
end
post '/recipes' do
@new_recipe = Recipe.new(
{ name: params["name"],
rating: params["rating"],
prep_time: params["time"],
description: params["description"],
done: false }
)
@updated = Cookbook.new('recipes.csv')
@updated.add_recipe(@new_recipe)
@cookbook = Cookbook.new('recipes.csv').all
erb :index
end
get '/delete/:recipe' do
end
get '/about' do
erb :about
end