app.py 627 B

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