DEV Community

Carlos Castaneda
Carlos Castaneda

Posted on

TIL Blog Day 9 - Sinatra

Sinatra

Sinatra is a DSL (domain specific language). This basically means that it is a specialized programming language that is designed for a specific narrow area of tasks. In Sinatra's case, this task is creating web applications. Right from the start, I really liked the simplicity that Sinatra provided when creating a quick web app.

To get Sinatra up and running, first install the sinatra gem and a server gem (puma in this case).
gem install sinatra
gem install puma

After that, you just have to require Sinatra at the top of your Ruby file.
require 'sinatra'

You can know start writing routes by using an HTTP method followed by the route you want to create and the do keyword followed by a block of code.

get '/' do
  "Hello world!"
end
Enter fullscreen mode Exit fullscreen mode

If you run your Ruby file it will output the string "Hello world!" in your browser.

Thats how easy it is to get up and running creating routes with Sinatra. You can quickly start creating your very own CRUD(create-read-update-delete) app!

While it is easy to set up, you can create large and complex web apps with many routes. The possibilities are endless!

Top comments (0)