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
84
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
43
Knowing mina deploy
lucianosousa
1
57
Creating your startup without Developer
lucianosousa
0
160
Patterns Falacy v2
lucianosousa
0
110
Project Management like Software Developer
lucianosousa
1
100
The Patterns Falacy - Rails Version
lucianosousa
1
95
Other Decks in Programming
See All in Programming
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
480
[JAWS-UG横浜 #76] イケてるアップデートを宇宙いち早く紹介するよ!
maroon1st
0
480
CSC305 Lecture 26
javiergs
PRO
0
140
ブラウザ単体でmp4書き出すまで - muddy-web - 2024-12
yue4u
3
480
LLM Supervised Fine-tuningの理論と実践
datanalyticslabo
7
1.3k
責務を分離するための例外設計 - PHPカンファレンス 2024
kajitack
6
1.4k
ある日突然あなたが管理しているサーバーにDDoSが来たらどうなるでしょう?知ってるようで何も知らなかったDDoS攻撃と対策 #phpcon.2024
akase244
1
140
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
210
PSR-15 はあなたのための ものではない? - phpcon2024
myamagishi
0
140
PHPで学ぶプログラミングの教訓 / Lessons in Programming Learned through PHP
nrslib
3
300
Androidアプリのモジュール分割における:x:commonを考える
okuzawats
1
130
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
270
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
45
7k
Writing Fast Ruby
sferik
628
61k
Code Reviewing Like a Champion
maltzj
520
39k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7k
Why Our Code Smells
bkeepers
PRO
335
57k
A Tale of Four Properties
chriscoyier
157
23k
Unsuck your backbone
ammeep
669
57k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
The Pragmatic Product Professional
lauravandoore
32
6.3k
Designing for Performance
lara
604
68k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
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