Working with Sinatra – Part 1

Sinatra is a DSL for creating quickly web applications in Ruby.

It’s true you can build many web applications with Ruby on Rails, but sometimes you don’t need too much, there are situations you need a simple application and RoR seems to be too much to solve it.

Install the gem

gem install sinatra

Create a ruby file

# mywebapp.rb
require 'sinatra'

get '/' do
  'Hello Sinatra'

Run it

ruby mywebapp.rb

Sinatra runs on http://localhost:4567 as default.

Captura de Tela 2015-04-25 às 09.01.35

This defines a simple HTTP method paired with a URL matching pattern. In this case, in the root page it will show a greeting.

get '/' do
  'Hello, Sinatra'

In part two of this post we will work with Views/Templates.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s