1
Fork 0
mirror of https://github.com/Steffo99/estus.git synced 2024-11-22 15:44:19 +00:00

Improve exception handling during startup

This commit is contained in:
Steffo 2017-09-12 11:15:36 +02:00
parent 42cdd9a0f7
commit 8833a76262
2 changed files with 4 additions and 3 deletions

View file

@ -1,3 +1,4 @@
flask flask
flask_sqlalchemy flask_sqlalchemy
sqlalchemy
bcrypt bcrypt

View file

@ -1,6 +1,7 @@
import os import os
from flask import Flask, session, url_for, redirect, request, render_template, abort from flask import Flask, session, url_for, redirect, request, render_template, abort
from flask_sqlalchemy import SQLAlchemy from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.exc import OperationalError
import bcrypt import bcrypt
app = Flask(__name__) app = Flask(__name__)
@ -203,14 +204,13 @@ def page_dashboard():
enti = Ente.query.all() enti = Ente.query.all()
conteggioservizi = dict() conteggioservizi = dict()
goldfish = url_for("static", filename="goldfish.png") goldfish = url_for("static", filename="goldfish.png")
terredicastello = url_for("static", filename="UTdClogo.png")
for ente in enti: for ente in enti:
conteggioservizi[ente.nomeente] = Servizio.query.join(Ente).filter_by(eid=ente.eid).count() conteggioservizi[ente.nomeente] = Servizio.query.join(Ente).filter_by(eid=ente.eid).count()
conteggioutenti = dict() conteggioutenti = dict()
for ente in enti: for ente in enti:
conteggioutenti[ente.nomeente] = Impiegato.query.join(Servizio).join(Ente).filter_by(eid=ente.eid).count() conteggioutenti[ente.nomeente] = Impiegato.query.join(Servizio).join(Ente).filter_by(eid=ente.eid).count()
return render_template("dashboard.htm", type="main", user=session["username"], return render_template("dashboard.htm", type="main", user=session["username"],
conteggioutenti=conteggioutenti, conteggioservizi=conteggioservizi, goldfish=goldfish, terredicastello=terredicastello) conteggioutenti=conteggioutenti, conteggioservizi=conteggioservizi, goldfish=goldfish)
@app.route('/ente_add', methods=['GET', 'POST']) @app.route('/ente_add', methods=['GET', 'POST'])
@ -550,6 +550,6 @@ if __name__ == "__main__":
secondary_dns="0.0.0.0") secondary_dns="0.0.0.0")
db.session.add(retenulla) db.session.add(retenulla)
db.session.commit() db.session.commit()
except Exception: except OperationalError:
db.session.rollback() db.session.rollback()
app.run(debug=True) app.run(debug=True)