-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.rb
52 lines (40 loc) · 947 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
45
46
47
48
49
50
51
52
# frozen_string_literal: true
require 'bundler/setup'
require 'sinatra/base'
require 'logger'
# require 'sequel'
# DB ||= Sequel.connect(ENV['DATABASE_URL'])
# require 'redis'
# REDIS ||= Redis.new(url: ENV['REDIS_URL'])
class AppName < Sinatra::Base
configure :development do
set :logging, Logger::DEBUG
end
configure :production do
set :raise_errors, false
set :show_exceptions, false
end
set :app_file, __FILE__
set :root, File.dirname(settings.app_file)
set :public_folder, File.join(settings.root, 'public')
before do
logger.debug(request.request_method) { "path: #{request.path_info}, params: #{params}" }
@title = 'AppName'
end
get '/' do
@title = 'Hello World!'
erb :index
end
get '/ping' do
halt :ok
end
# Errors
not_found do
@title = 'AppName | 404'
erb :not_found
end
error do
@title = 'AppName | Error'
erb :error
end
end