Skip to content

Instantly share code, notes, and snippets.

@trotter
Created April 27, 2012 00:46
Show Gist options
  • Save trotter/2504672 to your computer and use it in GitHub Desktop.
Save trotter/2504672 to your computer and use it in GitHub Desktop.
Sinatra CF app
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
require './app'
run Sinatra::Application
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