1 Star 0 Fork 0

鱼说还休/sinatra_demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
app.rb 2.00 KB
一键复制 编辑 原始数据 按行查看 历史
鱼说还休 提交于 2014-12-02 02:21 . make it better
require 'rubygems'
require 'sinatra'
require 'bundler'
# Setup load paths
Bundler.require
$: << File.expand_path('../', __FILE__)
$: << File.expand_path('../lib', __FILE__)
require 'dotenv'
Dotenv.load
# Require base
require 'sinatra/base'
require 'active_support/core_ext/string'
require 'active_support/core_ext/array'
require 'active_support/core_ext/hash'
require 'active_support/json'
libraries = Dir[File.expand_path('../lib/**/*.rb', __FILE__)]
libraries.each do |path_name|
require path_name
end
require 'app/extensions'
require 'app/models'
require 'app/helpers'
require 'app/routes'
module SinatraDemo
class App < Sinatra::Application
configure do
set :database, lambda {
db_name = ENV['MOPAAS_POSTGRESQL17678_NAME']||'ddthss5f2ke36t'
host_name = ENV['MOPAAS_POSTGRESQL17678_HOST']||'ec2-54-225-136-187.compute-1.amazonaws.com'
port = ENV['MOPAAS_POSTGRESQL17678_PORT']||'5432'
user_name = ENV['MOPAAS_POSTGRESQL17678_USERNAME']||'etwyiclzyogecj'
password = ENV['MOPAAS_POSTGRESQL17678_PASSWORD']||'RB6mGnFJ-V9Fr8pTmfYuLNpYM-'
"postgres://#{user_name}:#{password}@#{host_name}:#{port}/#{db_name}"
# ENV['DATABASE_URL'] || 'postgres://dbuser:z321318@localhost:5432/exampledb'
# ENV['DATABASE_PQ_URL']||'postgres://uc687502e02374df994a1337c323db416:p45b0763e53304f0ba930534ee6478581@10.4.7.20:5433/d2b71bcf422234eb0a07d70684d06169c'
}
end
configure :development, :staging do
database.loggers << Logger.new(STDOUT)
end
configure do
disable :method_override
disable :static
set :erb, escape_html: true
set :sessions, httponly: true, secure: production?,
secure: false, expire_after: 5.years, secret: ENV['SESSION_SECRET']
end
use Rack::Deflater
use Rack::Standards
use Routes::Static
unless settings.production?
use Routes::Assets
end
# Other routes:
use Routes::Albums
use Routes::Artists
end
end
include SinatraDemo::Models
include SinatraDemo::Helpers
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Ruby
1
https://gitee.com/messfairy/sinatra_demo.git
git@gitee.com:messfairy/sinatra_demo.git
messfairy
sinatra_demo
sinatra_demo
master

搜索帮助