Sinatra Basics : Modular Sinatra Application

Objective


To learn how to create a modular Sinatra application.

Steps


Step 1

Create hi.rb in your project folder.

require 'sinatra'

class HelloWorld < Sinatra::Base
  get '/' do
    'Hello, world!'
  end
end

Step 2

Create config.ru in your project folder.

require './hi'

run HelloWorld

Step 3

Run the application.

rackup

Step 4

Browse to http://localhost:9292

Summary


In this article, you learned how to create a modular Sinatra application.

Reference


Digital Ocean Sinatra Basics


Related Articles


Ace the Technical Interview

  • Easily find the gaps in your knowledge
  • Get customized lessons based on where you are
  • Take consistent action everyday
  • Builtin accountability to keep you on track
  • You will solve bigger problems over time
  • Get the job of your dreams

Take the 30 Day Coding Skills Challenge

Gain confidence to attend the interview

No spam ever. Unsubscribe anytime.