12345678910111213141516171819202122232425262728293031323334 |
- """
- @author: luojunhui
- """
- from quart import Quart
- from routes import VTARoutes
- from applications import AsyncMySQLClient
- # 初始化 App
- app = Quart(__name__)
- AsyncMySQL = AsyncMySQLClient(app)
- app_routes = VTARoutes(AsyncMySQL)
- 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)
|