Running a Ruby Server has never been easier

May 6th, 2008

What?

Sinatra - the sleekest ruby server out there. Very appropriately named

Why?

I have a good friend who’s learning to program - we started with ruby, and are now venturing into the messy world of html/css/javascript.

One of the biggest challenges in getting started with this stuff is to *get started.* Installation of Apache is not necessarily difficult, but if you want more dynamic scripting (say ruby), things can get messy.

Sinatra makes it super easy. 

How?

Super easy. Just:

sudo gem install sinatra
echo "require 'rubygems'; require 'sinatra'" > sinatra-server.rb
ruby sinatra-server.rb
# == Sinatra has taken the stage on port 4567 for development

That’s it. now go enjoy sinatra at http://localhost:4567.

 

Default Sinatra web server index document

 

To handle a request, simply edit your sinatra-server.rb file:

require 'rubygems'
require 'sinatra' 

get "/:name" do
  "Hello #{params[:name]}!"
end

Find more details in this great Sinatra tutorial

2 Responses to “Running a Ruby Server has never been easier”

  1. rourryrex Says:

    Hello my friends :)
    ;)

  2. Wave Invites Says:

    Wave Invites…

    What a refreshing topic! I really enjoyed your point of view and can’t wait to read some of your upcomming posts. I’m going to link to your blog if you don’t mind as I think my readers might find some value in your topics….

Leave a Reply