""" @author: luojunhui """ from quart import Quart from server.routes import Routes from applications.db import AsyncMySQLClient from applications.config import Config # 初始化 App app = Quart(__name__, static_folder='applications/static') config = Config() # 注册连接池 AsyncMySQL = AsyncMySQLClient(app) app_routes = Routes(AsyncMySQL, config) app.register_blueprint(app_routes) @app.before_serving async def init_db(): """ 初始化 :return: """ await AsyncMySQL.init_pool() @app.after_serving async def close_db(): """ 关闭连接 :return: """ await AsyncMySQL.close_pool() if __name__ == '__main__': app.run(debug=True)