forked from rDrama/rDrama
commit only when status code is 200
parent
e022b29ef6
commit
1367d944da
|
@ -94,14 +94,19 @@ def before_request():
|
||||||
@app.teardown_appcontext
|
@app.teardown_appcontext
|
||||||
def teardown_request(error):
|
def teardown_request(error):
|
||||||
if hasattr(g, 'db') and g.db:
|
if hasattr(g, 'db') and g.db:
|
||||||
g.db.commit()
|
g.db.rollback()
|
||||||
g.db.close()
|
g.db.close()
|
||||||
|
del g.db
|
||||||
stdout.flush()
|
stdout.flush()
|
||||||
|
|
||||||
@app.after_request
|
@app.after_request
|
||||||
def after_request(response):
|
def after_request(response):
|
||||||
response.headers.add("Strict-Transport-Security", "max-age=31536000")
|
response.headers.add("Strict-Transport-Security", "max-age=31536000")
|
||||||
response.headers.add("X-Frame-Options", "deny")
|
response.headers.add("X-Frame-Options", "deny")
|
||||||
|
if response.status_code == 200:
|
||||||
|
g.db.commit()
|
||||||
|
g.db.close()
|
||||||
|
del g.db
|
||||||
return response
|
return response
|
||||||
|
|
||||||
if app.config["SERVER_NAME"] == 'localhost':
|
if app.config["SERVER_NAME"] == 'localhost':
|
||||||
|
|
|
@ -35,4 +35,6 @@ def cron(every_5m, every_1h, every_1d, every_1mo):
|
||||||
|
|
||||||
if every_1mo:
|
if every_1mo:
|
||||||
give_monthly_marseybux_task()
|
give_monthly_marseybux_task()
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
||||||
|
g.db.close()
|
Loading…
Reference in New Issue