123456789101112131415161718192021222324252627282930313233 |
- """
- @author: luojunhui
- """
- from quart import Quart
- from routes import AlgRoutes
- from applications import AsyncMySQLClient
- app = Quart(__name__)
- AsyncMySQL = AsyncMySQLClient(app)
- app_routes = AlgRoutes(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, host="0.0.0.0", port=6060)
|