async_app.py 641 B

123456789101112131415161718192021222324252627282930313233343536
  1. """
  2. @author: luojunhui
  3. """
  4. import jieba
  5. from quart import Quart
  6. from applications.routes import video_score_blueprint
  7. from applications.model_init import Models
  8. # 初始化 App
  9. app = Quart(__name__)
  10. # 注册蓝图
  11. app.register_blueprint(video_score_blueprint)
  12. @app.before_serving
  13. async def before_serving():
  14. """
  15. 在服务器正式开始接受请求之前加载模型
  16. :return: None
  17. """
  18. Models()
  19. @app.before_serving
  20. async def preload_jieba():
  21. """
  22. 异步预加载jieba词典
  23. :return:
  24. """
  25. jieba.initialize()
  26. print("jieba 缓存加载完成")
  27. if __name__ == '__main__':
  28. app.run(debug=True)