-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.rb
74 lines (53 loc) · 1.03 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
64
65
66
67
68
69
70
71
72
73
74
require 'sinatra'
require 'rubygems'
require 'bundler/setup'
# require "erb"
# configure { set :server, :puma }
# set :bind, '192.168.1.9'
class Application < Sinatra::Base
def https_required!
if settings.production? && request.scheme == 'http'
headers['Location'] = request.url.sub('http', 'https')
halt 301, "https required\n"
end
end
before "/*" do
https_required!
end
get '/' do
erb :index
end
get '/about' do
erb :about
end
get '/skills' do
erb :skills
end
get '/projects' do
erb :projects
end
get '/running' do
erb :running
end
get '/contact' do
erb :contact
end
#test stuff
get '/time' do
code = "<%= Time.now %>"
erb code
end
get '/test' do
erb :test
end
get '/sinatra' do
erb :sinatra
end
get '/api/test' do
content_type :json
{ test: "this is a test" }.to_json
end
before "/api/test" do
https_required!
end
end