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
440
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
38
Mobile Games are Living Organisms, Too
mitsuhiko
0
24
We gave a Mouse an NDK
mitsuhiko
0
460
Debug is the new Release
mitsuhiko
1
410
A Future Python
mitsuhiko
0
2.2k
Failing in Rust
mitsuhiko
5
770
A Python for Future Generations
mitsuhiko
19
8.6k
Rust at Sentry
mitsuhiko
4
890
My Python is Rusting
mitsuhiko
2
1.5k
Other Decks in Programming
See All in Programming
ふんわり理解するcontext
rukiadia
1
180
Pythonによる開発をアップデートするライブラリの紹介
daikikatsuragawa
1
600
レビュー駆動学習のススメ_StaPy#83
soogie
0
320
atama plusの開発チームはどのように「不確実性」に向き合ってきたか〜2022夏版〜
atamaplus
3
610
Dagger, la CI, autrement
guikingone
1
110
料理の注文メニューの3D化への挑戦
hideg
0
290
ESM移行は無理だけどおれもSindreのライブラリが使いたい!
sosukesuzuki
2
550
ストア評価「2.4」だったCOCOARアプリを1年で「4.4」になんとかした方法@Cloud CIRCUS Meetup #2
1901drama
0
180
「困りごと」から始める個人開発
ikumatadokoro
4
250
読みやすいコード クラスメソッド 2022 年度新卒研修
januswel
0
2.9k
FutureCon 2022 FlutterアプリのPerformance測定
harukafujita
0
140
段階的な技術的負債の解消方法.pdf
ko2ic
2
930
Featured
See All Featured
A Tale of Four Properties
chriscoyier
149
21k
How To Stay Up To Date on Web Technology
chriscoyier
780
250k
Embracing the Ebb and Flow
colly
73
3.4k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
226
15k
Making the Leap to Tech Lead
cromwellryan
113
7.4k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
223
49k
Mobile First: as difficult as doing things right
swwweet
213
7.6k
Web Components: a chance to create the future
zenorocha
303
40k
A Philosophy of Restraint
colly
192
15k
Three Pipe Problems
jasonvnalue
89
8.7k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
29
4.4k
The Mythical Team-Month
searls
210
39k
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/