Sha256: bea6de22470c599e8dc000ec0e34ff6b6ced7cf74ed9b72f420de30def78642d

Contents?: true

Size: 888 Bytes

Versions: 30

Compression:

Stored size: 888 Bytes

Contents

$:.unshift( "../lib" )
require 'capcode'

module Capcode
  class HTTPError
    def r404(f)
      "#{f} not found !!!"
    end
  end
  
  class Index < Route '/'
    def get
      redirect( Hello, session[:user] )
    end
  end
  
  class Hello < Route '/hello/(.*)'
    def get( you )
      if you.nil?
        redirect( WhoAreYou )
      else
        " 
          Hello #{you}<br />
          Clic <a href='#{URL(Hello)}'>here</a> if hou want to change your name
        "
      end
    end
  end
  
  class WhoAreYou < Route '/who_are_you'
    def get
      '
        Please, enter your name :<br />
        <form method="POST">
          <input type="text", name="user"><br />
          <input type="submit">
        </form>
      '
    end
    def post
      session[:user] = params['user']
      redirect( Index )
    end
  end
end

Capcode.run( :port => 3000, :host => "localhost" )

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
Capcode-1.0.0 examples/session.rb
Capcode-0.9.9 examples/session.rb
Capcode-0.9.8 examples/session.rb
Capcode-0.9.7 examples/session.rb
Capcode-0.9.6 examples/session.rb
Capcode-0.9.5 examples/session.rb
Capcode-0.9.4 examples/session.rb
Capcode-0.9.3 examples/session.rb
Capcode-0.9.2 examples/session.rb
Capcode-0.9.1 examples/session.rb
Capcode-0.9.0 examples/session.rb
Capcode-0.8.9 examples/session.rb
Capcode-0.8.8 examples/session.rb
Capcode-0.8.7 examples/session.rb
Capcode-0.8.6 examples/session.rb
Capcode-0.8.5 examples/session.rb
Capcode-0.8.4 examples/session.rb
Capcode-0.6.2 examples/session.rb
Capcode-0.7.0 examples/session.rb
Capcode-0.7.1 examples/session.rb