Permalink
Browse files

add form.rb

  • Loading branch information...
1 parent 4b02792 commit 1ec04d2c4dce2deeb959ebae5d6530171234652e season committed Sep 14, 2011
Showing with 29 additions and 0 deletions.
  1. +23 −0 form.rb
  2. +5 −0 views/mainform.erb
  3. +1 −0 views/result.erb
View
23 form.rb
@@ -0,0 +1,23 @@
+ require 'sinatra'
+
+ helpers do
+ include Rack::Utils
+ alias_method :h, :escape_html
+ end
+
+ get '/' do
+ erb :mainform
+ end
+
+ post '/result' do
+ erb :result, :locals => { :username => request.POST[:username] }
+ end
+
+ get '/other/:name' do
+ erb :result, :locals => { :username => params[:name] }
+ end
+
+ get '/moar' do
+ erb :result, :locals => { :username => request.GET.to_s }
+ end
+
View
@@ -0,0 +1,5 @@
+<form method="POST" action="/result">
+ <label for="username">Enter Username:</label>
+ <input type="text" id="username" name="username" />
+ <input type="submit" />
+</form>
View
@@ -0,0 +1 @@
+<p>Welcome, <%=h username %>!</p>

0 comments on commit 1ec04d2

Please sign in to comment.