Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Sinatra::Ftw
Search
Luciano Sousa
September 18, 2010
Programming
0
100
Sinatra::Ftw
An introduction about Sinatra Framework
Luciano Sousa
September 18, 2010
Tweet
Share
More Decks by Luciano Sousa
See All by Luciano Sousa
Playing with Sorbet
lucianosousa
0
52
Knowing mina deploy
lucianosousa
1
76
Creating your startup without Developer
lucianosousa
0
170
Patterns Falacy v2
lucianosousa
0
120
Project Management like Software Developer
lucianosousa
1
110
The Patterns Falacy - Rails Version
lucianosousa
1
110
Other Decks in Programming
See All in Programming
Rで始めるML・LLM活用入門
wakamatsu_takumu
0
170
Ruby x Terminal
a_matsuda
7
590
文字コードの話
qnighy
44
17k
Codex の「自走力」を高める
yorifuji
0
1k
あなたはユーザーではない #PdENight
kajitack
4
340
AI時代でも変わらない技術コミュニティの力~10年続く“ゆるい”つながりが生み出す価値
n_takehata
2
660
Rails Girls Tokyo 18th GMO Pepabo Sponsor Talk
yutokyokutyo
0
210
TROCCOで実現するkintone+BigQueryによるオペレーション改善
ssxota
0
140
株式会社 Sun terras カンパニーデック
sunterras
0
2k
PJのドキュメントを全部Git管理にしたら、一番喜んだのはAIだった
nanaism
0
240
Docコメントで始める簡単ガードレール
keisukeikeda
1
100
nilとは何か 〜interfaceの構造とnil!=nilから理解する〜
kuro_kurorrr
3
1.7k
Featured
See All Featured
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.2k
Fireside Chat
paigeccino
42
3.8k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
1.9k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.1k
SEO for Brand Visibility & Recognition
aleyda
0
4.3k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.1k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.1k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.2k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
210
Statistics for Hackers
jakevdp
799
230k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Transcript
http://twitter.com/lucianosousa 1 Sinatra::Ftw Luciano Sousa
[email protected]
http://lucianosousa.net http://twitter.com/lucianosousa http://github.com/lucianosousa
http://twitter.com/lucianosousa 2 Sinatra::WTF? ✔ Micro Framework web ✔ DSL ✔
Rotas ✔ Múltiplos Templates ✔ Filtros ✔ Exemplos
http://twitter.com/lucianosousa 3 Sinatra::Description Micro Framework para desenvolvimento de aplicações web
com o mínimo de esforço.
http://twitter.com/lucianosousa 4 Sinatra::DSL get '/hi' do “hello world!” end Domain
Specific Language
http://twitter.com/lucianosousa 5 Sinatra::Routes get '/' do “get in index” end
post '/' do “post in index” end put '/' do “put in index” end delete '/' do “delete in index” end get '/:name' do “Hello #{params[:name]}!” end
http://twitter.com/lucianosousa 6 Sinatra::Templates get '/' do “hello world!” end get
'/' do erb :index end get '/' do haml :index end get '/' do erubis :index end
http://twitter.com/lucianosousa 7 Sinatra::Layout get '/' do erb :index end Carrega
arquivo arquivo layout.template dentro da pasta views automagicamente
http://twitter.com/lucianosousa 8
http://twitter.com/lucianosousa 9
http://twitter.com/lucianosousa 10
http://twitter.com/lucianosousa 11
http://twitter.com/lucianosousa 12 Sinatra::Helpers helpers do def sum(value) "Result: #{value.to_i+100}" end
end get '/:value' do sum(params[:value]) end Obs: O parâmetro :value é passado como string para o helper.
http://twitter.com/lucianosousa 13
http://twitter.com/lucianosousa 14 Sinatra::Filters after do puts "Response status is: #{response.status}"
end
http://twitter.com/lucianosousa 15
http://twitter.com/lucianosousa 16 Sinatra::Example