gemでインストール
$ sudo gem install sinatra
Password:
Successfully installed rack-0.9.1
Successfully installed sinatra-0.9.1.1
2 gems installed
Installing ri documentation for rack-0.9.1...
Installing ri documentation for sinatra-0.9.1.1...
Installing RDoc documentation for rack-0.9.1...
Installing RDoc documentation for sinatra-0.9.1.1...
$ mkdir test
$ cd test/
$ touch test.rb
test.rbを編集
$ emacs test.rb
require 'rubygems'
require 'sinatra'
get '/' do
'Hello world'
end
get '/hello/:name' do |n|
"Hello #{params[:name]}"
end
サーバを立ち上げて実行
$ ruby test.rb
== Sinatra/0.9.1.1 has taken the stage on 4567 for development with backup from Thin
>> Thin web server (v1.0.0 codename That's What She Said)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:4567, CTRL+C to stop
http://0.0.0.0:4567/にアクセス