123456789101112131415161718192021222324252627282930 |
- import jieba
- from quart import Quart
- from applications.config import LOCAL_MODEL_CONFIG, DEFAULT_MODEL
- from applications.utils.milvus import milvus_collection
- from applications.utils.mysql import mysql_manager
- from routes import server_routes
- app = Quart(__name__)
- MODEL_PATH = LOCAL_MODEL_CONFIG[DEFAULT_MODEL]
- # 注册路由
- app_route = server_routes(mysql_manager, milvus_collection)
- app.register_blueprint(app_route)
- @app.before_serving
- async def startup():
- print("Starting application...")
- await mysql_manager.init_pools()
- print("Mysql pools init successfully")
- print("Loading jieba dictionary...")
- jieba.initialize()
- print("Jieba dictionary loaded successfully")
- @app.after_serving
- async def shutdown():
- print("Shutting down application...")
- await mysql_manager.close_pools()
|