I am developing an application in Flask and requires DB, so I have:
app = Flask(__name__) @app.before_request def init_db_connection:
On the development server (app.run ()) this is not the best place to initialize the database, I think, because the database will also be initialized even when the request comes for a static file. In production, I can have a separate web server serving static files, so this should not be a problem.
But still, I think this is the right way to initialize the database, or is it better, for example, to initialize the database in Blueprint, which is used at this moment? I just want to know the best practices and how you guys are :)
Thanks!
source share