I don’t need to
CROSS THE ALPS
I just need a
SIMPLE WEBSITE!
Sheesh.
Slide 5
Slide 5 text
No content
Slide 6
Slide 6 text
EXTENSIONS!
EXTENSIONS!
Slide 7
Slide 7 text
EXTENSIONS!
EXTENSIONS!
Sorry, getting ahead
of myself there...
Slide 8
Slide 8 text
SIMPLE
Flask gives you three main things:
URL Routing
Templates
Error handling & debugger
mysite.com/foo
goes to foo_view()
powered by Jinja2!
is that four things? OK, fine, four main things.
Slide 9
Slide 9 text
Example Time!
Slide 10
Slide 10 text
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run()
$ pip install Flask
$ python hello.py
* Running on http://localhost:5000/
A full Flask application:
Running it:
Slide 11
Slide 11 text
from flask import render_template
@app.route('/hello/')
@app.route('/hello/')
def hello(name=None):
return render_template('hello.html', name=name)
Hello from Flask
{% if name %}
Hello {{ name }}!
{% else %}
Hello World!
{% endif %}
Templates!
Slide 12
Slide 12 text
No content
Slide 13
Slide 13 text
Demo Time!
Slide 14
Slide 14 text
HOORAY! NOW I
CAN SHOW OFF MY
CAT PICTURES!
But now I want to add
a rating system and a guestbook!
I CAN HAZ
DATABASE?
Slide 15
Slide 15 text
EXTENSIONS!
EXTENSIONS!
Slide 16
Slide 16 text
No content
Slide 17
Slide 17 text
NEED SOMETHING WEBSCALE?
or just use the database's Python module directly
Slide 18
Slide 18 text
WHAT ELSE
YA GOT
Slide 19
Slide 19 text
Admin interface? Check. Flask-Admin
Form management? Check.
Slide 20
Slide 20 text
Caching?
Email?
OAuth?
REST APIs?
Markdown?
I wrote that last one!
Slide 21
Slide 21 text
OTHER COOL THINGS
(that I don't really have time to talk about right now)
thread-local
response objects
session management
blueprints
redirect() and
abort() functions
real WSGI
support
static file
optimizations
unit test support message flashing
THESE ARE ALL BUILT-IN
Slide 22
Slide 22 text
1900 LINES
of Python code
250+ PAGES
of documentation
Flask is documented just as well as Django,
and that documentation is better organized
Slide 23
Slide 23 text
No content
Slide 24
Slide 24 text
WRAP-UP
DJANGO is LARGE and MONOLITHIC
FLASK is SMALL and EXTENSIBLE
difficult to change/replace built-in components
steep learning curve
little flexibility
add components/complexity as necessary
learn as you go
write your app the way you want
Slide 25
Slide 25 text
ANY QUESTIONS?
flask.pocoo.org
David Baumgold // @singingwol!oy