forked from MarseyWorld/MarseyWorld
commit only when status code is 200
parent
e022b29ef6
commit
1367d944da
|
@ -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':
|
||||
|
|
|
@ -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()
|
Loading…
Reference in New Issue