commit only when status code is 200

master
Aevann1 2022-06-26 07:37:36 +02:00
parent e022b29ef6
commit 1367d944da
2 changed files with 9 additions and 2 deletions

View File

@ -94,14 +94,19 @@ def before_request():
@app.teardown_appcontext
def teardown_request(error):
if hasattr(g, 'db') and g.db:
g.db.commit()
g.db.rollback()
g.db.close()
del g.db
stdout.flush()
@app.after_request
def after_request(response):
response.headers.add("Strict-Transport-Security", "max-age=31536000")
response.headers.add("X-Frame-Options", "deny")
if response.status_code == 200:
g.db.commit()
g.db.close()
del g.db
return response
if app.config["SERVER_NAME"] == 'localhost':

View File

@ -35,4 +35,6 @@ def cron(every_5m, every_1h, every_1d, every_1mo):
if every_1mo:
give_monthly_marseybux_task()
g.db.commit()
g.db.commit()
g.db.close()