Sha256: b65e90cba3ce48a53a8fc81071b09c50d7ee421667d40807b948fa6a3f0dfc0a

Contents?: true

Size: 820 Bytes

Versions: 1

Compression:

Stored size: 820 Bytes

Contents

# * George Moschovitis  <gm@navel.gr>
# (c) 2004-2005 Navel, all rights reserved.
# $Id$

$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')

require 'nitro'
require 'nitro/adaptors/webrick'

include N

class Wee < Controller

	def index
		counter = session[:counter] || 0

		(o = @out).html {
			o.h1 'Hello world'
			o << 'This is ' 
			o.b { o << 'BOLD' }
			o.p {
				o << "Here is the counter: #{counter}"
			}
			o.p {
				o << '<a href="inc_counter">Increase</a> the counter.'
			}
			o.p {
				o << '<a href="reset_counter">Reset</a> the counter.'
			}
		}
	end

	def inc_counter
		session[:counter] ||= 0
		session[:counter] += 1
	end
	
	def reset_counter
		session[:counter] = 0
	end

end

conf = {
	:host => 'localhost',
	:port => 8069,
	:dispatcher => Dispatcher.new(Wee)
}

Webrick.start(conf)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nitro-0.9.5 examples/wee_style/wee.rb