Created
April 27, 2012 00:46
-
-
Save trotter/2504672 to your computer and use it in GitHub Desktop.
Sinatra CF app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'mongo' | |
require 'json' | |
begin | |
require 'cfruntime/mongodb' | |
connection = CFRuntime::MongoClient.create_from_svc('mongodb-sinatra') | |
$mongo = connection.db | |
rescue | |
$mongo = Mongo::Connection.new("localhost", 27017).db("db") | |
end | |
get '/' do | |
mongo_info = ENV['VMC_MONGODB'] | |
return <<-EOS | |
<h1>Welcome to CF: #{ENV['VMC_APP_HOST']}:#{ENV['VMC_APP_PORT']}</h1> | |
<h2>Mongo info: #{mongo_info}</h2> | |
<h2>Mongo: #{$mongo.collection_names}</h2> | |
<p>#{ENV.inspect}</p> | |
EOS | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require './app' | |
run Sinatra::Application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source :rubygems | |
gem 'sinatra' | |
gem 'thor' | |
gem 'mongo' | |
gem 'json' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment