Automatically close db connexion

This commit is contained in:
augustin64 2023-06-24 16:05:50 +02:00
parent 566caac0a5
commit c735b1e496

View File

@ -82,5 +82,13 @@ def add_user():
return render_template("auth/register.html", albums=get_all_albums(), user=current_user) return render_template("auth/register.html", albums=get_all_albums(), user=current_user)
# Automatically close db after each request
@app.after_request
def after_request(response):
if ('db' in g) and (g.db is not None):
g.db.close()
return response
if __name__ == "__main__": if __name__ == "__main__":
app.run(host="0.0.0.0") app.run(host="0.0.0.0")