Skip to content
A simple Hello, World! server app using Sinatra.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.bundle
docs
vendor/cache
.gitignore
.ruby-version
Gemfile
Gemfile.lock
LICENSE
Procfile
README.md
api.rb
config.ru

README.md

sinatra-hello-world

A simple “Hello world!” Sinatra app that works with rbenv.

Create from scratch

# create the Sinatra source
echo "require 'sinatra'
get '/' do
  'Hello world!'
end" > api.rb

# declare dependencies  
echo "source 'https://rubygems.org'
gem 'sinatra'
gem 'unicorn'
gem 'json'" > Gemfile   
  
# install and package dependencies
rbenv exec bundle package --path=vendor/bundle

# create a Procfile and config.ru for Heroku
echo "web: bundle exec unicorn --port \$PORT
local: rbenv exec bundle exec unicorn --port \$PORT" > Procfile

echo "require './api'
run Sinatra::Application" > config.ru

Deployment

Local

rbenv exec bundle exec ruby api.rb &
open http://localhost:4567

Locally with Heroku

heroku local local &
open http://0.0.0.0:5000

Remote

Heroku

heroku create # make sure your ‘heroku’ git remote points to the correct app's git url, like if there was a previous one
git push heroku master
heroku open

References

Note: References preserved as PDFs in docs/.

Contribute

Issues and pull requests are welcome!

If this project helped you, please consider leaving a tip 🤗

Do you need help with a project? I'm currently available for hire or contract..

You can’t perform that action at this time.