12345678910111213141516171819202122232425262728293031323334 |
- """
- @author: luojunhui
- """
- from quart import Quart
- from applications.routes import Routes
- from applications.functions.async_mysql import AsyncMySQLClient
- # 初始化 App
- app = Quart(__name__, static_folder='applications/static')
- AsyncMySQL = AsyncMySQLClient(app)
- app_routes = Routes(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)
|