1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00
sinatra/README
Blake Mizerany 85e1a4c944 docs
2007-10-04 15:40:12 -07:00

57 lines
1.3 KiB
Text

Sinatra (C) 2007 By Blake Mizerany
= Classy web-development dressed in a DSL
== Install!
sudo gem install sinatra -y
== Use!
I'm going to move quick. I'll let you drool at your own pace.
- Create a file called lyrics.rb (or any name you like)
- Add
require 'rubygems'
require 'sinatra'
- Run (yes, with just ruby)
% ruby lyrics.rb
== Sinata has taken the stage on port 4567!
- Take a moment and view the default page http://localhost:4567. Go ahead and bask in it's glory.
* Notice:
* It didn't create any page to show you that default page (just a cool thing to see, that's all)
* There was nothing generated other than a log file
* Sinatra is a really cool name for a web-framework that's a DSL
- Modify lyrics.rb by adding:
get '/' do
'Hello World'
end
- Refresh (no need to restart Sinatra):
http://localhost:4567
- Modify again (then refresh):
get '/' do
<<-HTML
<form action='/' method="POST">
<input type="text" name="name" />
<input type="submit" value="Say my name!" />
</form>
HTML
end
post '/' do
"Hello #{params[:name] || 'World'}!"
end
- Homework:
Use the Sinatra::Erb::EventContext or Sinatra::Haml::EventContext to do the same. Do them inline and as template files.