Off the ground with Sinatra
Starting Sinatra from scratch can leave people wondering what to do if they have never used it before. So here is my step by step to start a Sinatra app from scratch:
gem install sinatra
touch hi.rb
Edit hi.rb and add these lines (any text editor will do):
require 'sinatra'
get '/' do
"Hello World!"
end
Save and Quit.
Finally, run this command:
ruby -rubygems hi.rb
You will see this (or similar) output:
Sinatra/1.3.3 has taken the stage on 4567 for development
Thin web server (v1.5.0 codename Knife)
Maximum connections set to 1024
Listening on 0.0.0.0:4567, CTRL+C to stop
Now you can access your new Sinatra app from the above URL:
http://0.0.0.0:4567/
Written by Richard Howard
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#