Skip to content

Latest commit

 

History

History
93 lines (68 loc) · 1.26 KB

sinatra.md

File metadata and controls

93 lines (68 loc) · 1.26 KB

How to Sinatra

How to create sinatra app push to heroku

mkdir sinatra
cd sinatra
gem install sinatra

arcade.rb

require 'sinatra'
require 'json'

before do
  content_type :json
end

get '/hi' do
  "Hello World"
end

get '/game/1' do
  {
      game: "Wake me Up",
      year: "1984"
  }.to_json
end

get '/game/2' do
    send_file 'test.json'
end

config.ru

require './arcade'
run Sinatra::Application

Gemfile

source 'https://rubygems.org'
gem 'sinatra'

ruby arcade.rb // http://localhost:4567

Setup repos and push

bundle install
git init
git add .
git commit -m "init"

heroku login
heroku create
git push heroku master
heroku ps:scale web=1

heroku open

https://fierce-retreat-36855.herokuapp.com/

How to add a new end point

Goto sinatra repo dir.

Make changes

  • Update rb files
  • Add to config.ru

To push

> heroku login
> git push heroku main
> https://git.heroku.com/fierce-retreat-36855

Links that help