2012年4月2日月曜日

はじめてのSinatra

見よう見まねで、とりあえず
http://www.sinatrarb.com/intro-jp.htmlを試してみた♪
あっさり動いて感動!

gemのインストール
$ gem install sinatra
Fetching: rack-1.4.1.gem (100%)
Fetching: rack-protection-1.2.0.gem (100%)
Fetching: sinatra-1.3.2.gem (100%)
Successfully installed rack-1.4.1
Successfully installed rack-protection-1.2.0
Successfully installed sinatra-1.3.2
3 gems installed
Installing ri documentation for rack-1.4.1...
Installing ri documentation for rack-protection-1.2.0...
Installing ri documentation for sinatra-1.3.2...
Installing RDoc documentation for rack-1.4.1...
Installing RDoc documentation for rack-protection-1.2.0...
Installing RDoc documentation for sinatra-1.3.2...

アプリの作成
# myapp.rb
require 'sinatra'
get '/' do
  'Hello world!'
end

Webサーバーの起動
$ ruby -rubygems myapp.rb
[2012-04-02 16:37:45] INFO  WEBrick 1.3.1
[2012-04-02 16:37:45] INFO  ruby 1.9.2 (2011-07-09) [x86_64-linux]
== Sinatra/1.3.2 has taken the stage on 4567 for development with backup from WEBrick
[2012-04-02 16:37:45] INFO  WEBrick::HTTPServer#start: pid=24126 port=4567

アクセス
http://localhost:4567/

0 件のコメント:

コメントを投稿

注: コメントを投稿できるのは、このブログのメンバーだけです。