Skip to content

Latest commit

 

History

History
76 lines (56 loc) · 1.04 KB

sinatra.md

File metadata and controls

76 lines (56 loc) · 1.04 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 create
git push heroku master
heroku ps:scale web=1

heroku open

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

Links that help