-
-
Save kevinold/224234 to your computer and use it in GitHub Desktop.
Sinatra forms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Subject: Re: Newbie to Sinatra looking for example | |
# From: Ryan Tomayko <[email protected]> | |
# To: [email protected] | |
# Content-Type: text/plain; charset=UTF-8 | |
# | |
# > Alright, so I'm pretty new to both Sinatra and web applications, and I | |
# > was wondering if someone could write up a quick example use of | |
# > Sinatra. Basically I want to see how Sinatra handles <form>s in one | |
# > view, and then shows the input on a different view. | |
# > | |
# > I hope that doesn't sound too confusing. | |
require 'sinatra' | |
get '/' do | |
erb "<form method=POST><input name=mess></form>" | |
end | |
post '/' do | |
erb "Hot <%= escape_html(params[:mess]) %>" | |
end | |
__END__ | |
@@ layout | |
<!DOCTYPE html> | |
<html><%= yield %></html> | |
# tomayko.com/about |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment