diff --git a/partitioncloud/__init__.py b/partitioncloud/__init__.py index a76e837..f3512bd 100644 --- a/partitioncloud/__init__.py +++ b/partitioncloud/__init__.py @@ -82,5 +82,13 @@ def add_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__": app.run(host="0.0.0.0")