123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- """
- @author: luojunhui
- """
- from quart import Quart
- from routes import AlgRoutes
- from applications import AsyncMySQLClient
- from applications.algorthims import titleSimilarity
- 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.before_serving
- def init_bert_model():
- """
- 初始化bert模型
- :return:
- """
- Ts = titleSimilarity()
- Ts.loading_model()
- print("Bert Model has already loaded")
- @app.after_serving
- async def close_db():
- """
- 关闭连接
- :return:
- """
- await AsyncMySQL.close_pool()
- if __name__ == '__main__':
- app.run(debug=True)
|