""" @author: luojunhui """ from quart import Quart from routes import Routes from applications import AsyncMySQLClient # init app app = Quart(__name__) asyncMysql = AsyncMySQLClient(app) appRoutes = Routes(asyncMysql) app.register_blueprint(appRoutes) @app.before_serving async def initDB(): """ init db pool before server is up :return: """ await asyncMysql.initPool() @app.after_serving async def closeDB(): """ close db pool after server is down :return: """ await asyncMysql.closePool() if __name__ == '__main__': app.run(debug=True)