-
Notifications
You must be signed in to change notification settings - Fork 0
/
application.rb
44 lines (36 loc) · 948 Bytes
/
application.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
require 'sinatra'
require 'mongoid'
require 'lib/fail'
class Application < Sinatra::Base
set :root, File.dirname(__FILE__)
set :views, settings.root + '/templates'
set :public_folder, settings.root + '/public'
configure do
Mongoid.configure do |config|
name = "nsfail"
host = "localhost"
config.master = Mongo::Connection.new.db(name)
config.slaves = [
Mongo::Connection.new(host, 27017, :slave_ok => true).db(name)
]
config.persist_in_safe_mode = false
end
set :environment, :develop
set :dump_errors, true
set :haml, { :ugly=>true }
set :clean_trace, true
end
get '/' do
haml :index
end
get '/application.css' do
content_type 'text/css', :charset => 'utf-8'
sass :application, :style => :expanded
end
get '/fails.json' do
Fail.desc(:id).to_json
end
get '/cities.json' do
Fail.search([52.35000000, 4.91666700]).json
end
end