Quick Server-Side Sinatra Setup
Minimal, elegant Ruby backend without JavaScript nonsense.
Project Structure
my_app/
├── app.rb
├── views/
│ └── index.erb
├── public/
│ └── style.css
├── Gemfile
└── config.ru
Step-by-Step
- Install Sinatra
gem install sinatra
- Basic
app.rb
Template
require 'sinatra'
get '/' do
erb :index
end
- Create Views
<!-- views/index.erb -->
<h1>Hello, world</h1>
- Run It
ruby app.rb
- Production Ready with Rack
# config.ru
require './app'
run Sinatra::Application
rackup config.ru
TODO
- Add custom routes
- Add environment config (
dotenv
) - Connect to Postgres