Implemented db to backend code

This commit is contained in:
2026-03-07 17:27:10 +00:00
parent 26c25122cc
commit fa94974239

View File

@ -3,18 +3,40 @@ Imports all required blueprints and initalises the app.
Runs in debug mode if ran directly.
"""
import logging
import atexit
import dotenv
import flask
import db
from blueprints.projects import projectsBP
from blueprints.static import staticBP
logging.basicConfig(level=logging.DEBUG)
dotenv.load_dotenv()
app = flask.Flask(__name__)
db.init()
app.register_blueprint(projectsBP)
app.register_blueprint(staticBP)
def onClose():
"""
Safely close all blueprints and then the database.
"""
for bp in app.blueprints.values():
# If there is an onClose function to call
if callable(getattr(bp, "onClose", None)):
bp.onClose()
db.GLOBAL.close()
atexit.register(onClose)
if __name__ == '__main__':
print('Running in debug mode')
app.run(debug=True)