mirror of https://github.com/pallets/flask.git
Updated examples
This commit is contained in:
parent
115d31ddbf
commit
b51ecd7f21
|
@ -47,11 +47,10 @@ def before_request():
|
||||||
g.db = connect_db()
|
g.db = connect_db()
|
||||||
|
|
||||||
|
|
||||||
@app.after_request
|
@app.teardown_request
|
||||||
def after_request(response):
|
def teardown_request(exception):
|
||||||
"""Closes the database again at the end of the request."""
|
"""Closes the database again at the end of the request."""
|
||||||
g.db.close()
|
g.db.close()
|
||||||
return response
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
|
|
|
@ -82,11 +82,10 @@ def before_request():
|
||||||
[session['user_id']], one=True)
|
[session['user_id']], one=True)
|
||||||
|
|
||||||
|
|
||||||
@app.after_request
|
@app.teardown_request
|
||||||
def after_request(response):
|
def teardown_request(exception):
|
||||||
"""Closes the database again at the end of the request."""
|
"""Closes the database again at the end of the request."""
|
||||||
g.db.close()
|
g.db.close()
|
||||||
return response
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
|
|
Loading…
Reference in New Issue