Ruby installation

Installation and Usage of Sinatra in Ruby

Introducing the installation method and basic usage of Sinatra in Ruby. Sinatra is a lightweight web application framework that allows you to easily create applications.

Shou Arisaka
1 min read
Nov 21, 2025

Sinatra is a lightweight web application framework created in Ruby, characterized by being simple and easy to use. This article introduces the installation method and basic usage of Sinatra.

Installation

First, to install Sinatra, execute the following command.

gem install sinatra

Basic Usage

Introducing how to create a simple web application using Sinatra. Save the following code in a file called app.rb.

require 'sinatra'

get '/' do
  'Hello, world!'
end

This code creates a web application that displays the message “Hello, world!” using Sinatra.

Starting the Application

To start the application, execute the following command.

ruby app.rb -o 0.0.0.0

When you execute this command, Sinatra will wait for requests on port 4567 by default. When you access localhost:4567 in your browser, the message “Hello, world!” will be displayed.

References

Share this article

Shou Arisaka Nov 21, 2025

🔗 Copy Links