-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.rb
34 lines (27 loc) · 860 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
require 'rubygems'
require 'sinatra'
require 'hominid' # MailChimp
configure do
# MailChimp configuration: ADD YOUR OWN ACCOUNT INFO HERE!
set :mailchimp_api_key, "b5570879d08eed0513f6e19fef313059-us4"
set :mailchimp_list_name, "Info"
end
get '/' do
File.read(File.join('public', 'index.html'))
end
get '/testimonial' do
File.read(File.join('public', 'testimonial.html'))
end
post '/signup' do
email = params[:email]
unless email.nil? || email.strip.empty?
mailchimp = Hominid::API.new(settings.mailchimp_api_key)
list_id = mailchimp.find_list_id_by_name(settings.mailchimp_list_name)
raise "Unable to retrieve list id from MailChimp API." unless list_id
mailchimp.list_subscribe(list_id, email, {}, 'html', false, true, true, false)
end
"Success."
end
not_found do
'The item you are looking for was not found :('
end