Last active
January 12, 2019 16:43
-
-
Save seven1m/85a6ef819b32dc70db160d9dd27f91e0 to your computer and use it in GitHub Desktop.
Sinatra app boilerplate so I don't have to go hunting for these settings every time.
This file contains hidden or 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 'bundler/setup' | |
| require 'sinatra/base' | |
| require 'sinatra/reloader' | |
| unless File.exist?('session_secret.txt') | |
| puts 'Generating session_secret.txt with random number...' | |
| require 'securerandom' | |
| File.write('session_secret.txt', SecureRandom.hex(64)) | |
| puts '...done' | |
| end | |
| class App < Sinatra::Base | |
| enable :sessions | |
| set :session_secret, File.read('session_secret.txt') | |
| enable :static | |
| configure :production, :development do | |
| enable :logging | |
| end | |
| configure :development do | |
| register Sinatra::Reloader | |
| end | |
| get '/' do | |
| erb 'hello world' | |
| end | |
| run! if app_file == $0 | |
| end |
This file contains hidden or 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 App |
This file contains hidden or 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 'https://rubygems.org' | |
| gem 'sinatra' | |
| gem 'sinatra-contrib' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment