alg_app.py 572 B

123456789101112131415161718192021222324252627282930313233
  1. """
  2. @author: luojunhui
  3. """
  4. from quart import Quart
  5. from routes import AlgRoutes
  6. from applications import AsyncMySQLClient
  7. app = Quart(__name__)
  8. AsyncMySQL = AsyncMySQLClient(app)
  9. app_routes = AlgRoutes(AsyncMySQL)
  10. app.register_blueprint(app_routes)
  11. @app.before_serving
  12. async def init_db():
  13. """
  14. 初始化
  15. :return:
  16. """
  17. await AsyncMySQL.init_pool()
  18. @app.after_serving
  19. async def close_db():
  20. """
  21. 关闭连接
  22. :return:
  23. """
  24. await AsyncMySQL.close_pool()
  25. if __name__ == '__main__':
  26. app.run(debug=True, host="0.0.0.0", port=6060)