Classy web-development dressed in a DSL (official / canonical repo)
Ruby Other
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Sinatra (C) 2007 By Blake Mizerany

= Classy web-development dressed in a DSL

== Install!

  sudo gem install sinatra -y

== Use!

I'm going to move quick.  I'll let you drool at your own pace.

* Create a file called lyrics.rb (or any name you like)

* Add
    require 'rubygems'
    require 'sinatra'

* Run (yes, with just ruby)
    % ruby lyrics.rb
    == Sinata has taken the stage on port 4567!

* Take a moment and view the default page http://localhost:4567.  Go ahead and bask in it's glory.

* Notice:
  * It didn't create any page to show you that default page (just a cool thing to see, that's all)
  * There was nothing generated other than a log file
  * Sinatra is a really cool name for a web-framework that's a DSL

* Modify lyrics.rb by adding:
    get '/' do
      'Hello World'
* Refresh (no need to restart Sinatra):

* Modify again (then refresh):
    get '/' do
        <form action='/' method="POST">
          <input type="text" name="name" />
          <input type="submit" value="Say my name!" />
    post '/' do
      "Hello #{params[:name] || 'World'}!"

* Now you try:
  Use the Sinatra::Erb::EventContext or Sinatra::Haml::EventContext to do the same.  Do them inline and as template files.

* Learn more cool stuff:
  see Sinatra::Dsl

* Create your own plugins!
  1. Create a 'vendor' directory in your app directory
  2. Lay it out like:

     myapp.rb : root
        |- vendor
		     | - plugin_name
                   | - init.rb  # load and hook here
                   | - lib
                         |- modules/classes here

  3. Use it in your app!

  see $SINATRA_GEM_ROOT/vendor/erb or $SINATRA_GEM_ROOT/vendor/erb for examples.

* Tell!
We would love to here what you're doing with Sinatra and any cool patches/features you would like.  (blake { dot } mizerany [ at ] gmail)

* Talk!
IRC (  #sinatra)
Mailing List (

* Contribute

We're using git as our scm.. cuz.. it rocks.  You can get the latest source from

NOTE: You can also get tar'd snapshots of each commit there too.  So technically you don't need git to get the latest code.

It's probably going to happen.. you'll find a bug.  Please help by:

* Sending a message to with BUG: at the start of the subject (I'm working on a better tracking system)
* Please send patches or pull requests to (blake { dot } mizerany [ at ] gmail) don't forget the dot com. ;)

== Thanks!

- Ezra Zygmuntowicz ( for answering all those random questions over IM and all the poached code
- Ditto to Chris Wanstrath ( and helping me keep things simple, and some cool tricks
- Ari Lerner over at CitrusByte for ideas, code, and enthusiasm
- Koshi ( here at POTI, Inc. for the Sinatra mark
- Pete Golibersuch for the hat logo
- John Philip Green ( for motivation and evangelism
- The team here at for cool ideas