On 25 June 2015, Ned Jackson Lovely spoke about Flask at the Boston Django Users Meetup Group. I took some notes and am putting them here so I don't lose them; they may or may not be useful to others. Theses notes are not exhaustive.
Functions that are decorated with
@flaskapp.route() should return:
In theory, your function could return another Flask app, or spit out a WSGI callable that generated a massive CSV on the fly and streamed it to the user
You can do testing:
def test_splash(): client = app.test_client() response = client.get('/') assert response.status_code == 200 assert 'form' in response.data
The Werkzeug debugger is awesome
Defining filters for templates is possible (and ostensibly simple)
Sessions in Flask are interesting
If you write to a "second level" in
session, you need to set
session.modified = True for the changes to get written out:
session['first']['second'] = 'new thing' session.modified = True
Flashing is done with sessions, and is useful for displaying those one-time, web app-y messages like "Your post was submitted"
On a general Python note, contexts (
as) are really cool -- you only
have to implement two
__ methods to get the benefits of them
Some useful libraries: SQLAlchemy, WTForms
Flaskobjects with an additional "namespace"
To get GET/POST data, use