async_app.py 603 B

1234567891011121314151617181920212223242526272829303132333435
  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. if __name__ == '__main__':
  27. app.run(debug=True)