12345678910111213141516171819202122232425262728293031323334353637 |
- """
- @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(env="copy1")
- # 注册连接池
- AsyncMySQL = AsyncMySQLClient(app)
- app_routes = Routes(AsyncMySQL, config)
- app.register_blueprint(app_routes)
- @app.before_serving
- async def init_db():
- """
- 初始化
- :return:
- """
- await AsyncMySQL.initPool()
- @app.after_serving
- async def close_db():
- """
- 关闭连接
- :return:
- """
- await AsyncMySQL.closePool()
- if __name__ == '__main__':
- app.run(debug=True)
|