-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.rb
63 lines (48 loc) · 1.15 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
require 'sinatra'
require 'sinatra/activerecord'
require 'sinatra/reloader'
require 'sinatra/json'
configure :development, :test do
require 'pry'
end
configure do
set :views, 'app/views'
end
Dir[File.join(File.dirname(__FILE__), 'app', '**', '*.rb')].each do |file|
require file
also_reload file
end
get "/" do
@stories = Story.all
# @stories = @stories_escaped.content.gsub("\\", "")
# example = Story.create(name: "example", content: "This is a NOUN and a VERB.")
# hash = {"NOUN" => "#{noun}", "VERB" => "#{verb}"}
#
# string = example.content
#
# noun = "runner"
# verb = "run"
#
# hash.each do |key, value|
# string.gsub!(key, value)
# end
#
# string
erb :index
end
get "/stories.json" do
stories = Story.all
json({
stories: stories
})
end
post '/' do
noun = params[:noun]
verb = params[:verb]
time = params[:time]
content = "Now this is a story all about how my #{noun} got flipped #{verb} upside down. And I\'d like to take a #{time} just sit right down"
launcher_theme_song = Catalog.create(name: "Launchers Theme Song", content: content).to_json
end
get '/catalog' do
erb :catalog
end