Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Flask Lighting Talk
Armin Ronacher
June 12, 2010
Programming
1
460
Flask Lighting Talk
At DjangoCon.eu 2010
Armin Ronacher
June 12, 2010
Tweet
Share
More Decks by Armin Ronacher
See All by Armin Ronacher
The Snowball Effect of Open Source
mitsuhiko
0
150
Mobile Games are Living Organisms, Too
mitsuhiko
0
77
We gave a Mouse an NDK
mitsuhiko
0
510
Debug is the new Release
mitsuhiko
1
440
A Future Python
mitsuhiko
0
2.3k
Failing in Rust
mitsuhiko
5
790
A Python for Future Generations
mitsuhiko
20
8.7k
Rust at Sentry
mitsuhiko
4
940
My Python is Rusting
mitsuhiko
2
1.5k
Other Decks in Programming
See All in Programming
新卒2年目がデータ分析API開発に挑戦【Stapy#88】/data-science-api-begginer
matsuik
0
330
T3 Stack and TypeScript ecosystem
quramy
3
650
はてなリモートインターンシップ2022 Web API 講義資料
hatena
0
150
Hasura の Relationship と権限管理
karszawa
0
130
Git Rebase
bkuhlmann
10
1.2k
監視せなあかんし、五大紙だけにオオカミってな🐺🐺🐺🐺🐺
sadnessojisan
0
350
ITエンジニア特化型Q&Aサイトteratailを 言語、DB、クラウドなど フルリプレイスした話
leveragestech
0
370
Hono v3 - Do Everything, Run Anywhere, But Small, And Faster
yusukebe
4
120
状態ってなに?🙃
taro28
0
250
Refactor with using `available` and `deprecated`
417_72ki
3
370
社会人 20 年目エンジニア、発信で技術学びなおしてる話
e99h2121
1
130
An Advanced Introduction to R
nicetak
0
1.5k
Featured
See All Featured
10 Git Anti Patterns You Should be Aware of
lemiorhan
643
54k
Raft: Consensus for Rubyists
vanstee
130
5.7k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
351
21k
The Pragmatic Product Professional
lauravandoore
21
3.4k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
500
130k
A Tale of Four Properties
chriscoyier
149
21k
Documentation Writing (for coders)
carmenintech
51
2.9k
Building Adaptive Systems
keathley
27
1.3k
Typedesign – Prime Four
hannesfritz
34
1.5k
WebSockets: Embracing the real-time Web
robhawkes
58
6k
Music & Morning Musume
bryan
36
4.6k
Fantastic passwords and where to find them - at NoRuKo
philnash
31
1.8k
Transcript
a gentle introduction into a microframework with good intentions {
Armin Ronacher – http://lucumr.pocoo.org – http://twitter.com/mitsuhiko }
What is Flask? » A microframework » Reusing existing code
» Lots of documentation » Neat way to write small apps
Another µFramework? YES!
Under the Hood » Full power of Werkzeug » Jinja2
as a capable template engine
Under the Hood » 450 Lines of actual Code »
1000 Lines of Tests » 5000 Lines of Documentation
What does it do? » Cookie-based session support » Flashing
of messages » Preconfigured Jinja2 with autoescaping » Serves static files from “static” » Before/After Request hooks » Context local objects » RESTful URL mapping
What else? » Lots of documentation (120 A4 pages) »
Website with lots of snippets » Extension registry (OAuth, OpenID, XML- RPC, CSRF protection …) » Active Mailinglist and IRC Channel
Hello Flask from flask import Flask app = Flask(__name__) @app.route('/')
def index(): return 'Hello World!' if __name__ == '__main__': app.run(debug=True)
Hello Localhost $ python hello.py * Running on http://127.0.0.1:5000/ *
Restarting with reloader...
Rendering Templates from flask import render_template @app.route('/') def index():
return render_template('index.html', variable='value' )
The Request Data from flask import request, flash, redirect, \
url_for, request @app.route('/new-‐comment', methods=['GET', 'POST']) def new_comment(): if request.method == 'POST': Comment(request.form['name'], request.form['text']).save() flash('Comment was added') return redirect(url_for('show_comments')) return render_template('new_comment.html')
Before/After Request import sqlite3 from flask import g @app.before_request def
before_request(): g.db = sqlite3.connect(…) @app.after_request def after_request(response): g.db.close() return response
If Things Break
Where to get? $ pip install Flask http://github.com/mitsuhiko/flask http://flask.pocoo.org/