Enhance backend startup logging and API endpoint display

- Updated `run.py` to conditionally print startup information only in the reloader process to avoid duplicate logs in debug mode.
- Modified `__init__.py` to log startup and completion messages based on the reloader process condition.
- Added warnings suppression in `graph_builder.py` for Pydantic v2 regarding Field usage.
- Revised `ontology_generator.py` to enforce strict design guidelines for entity types and relationships, ensuring compliance with new requirements.
- Improved logging behavior in `logger.py` to prevent log propagation to the root logger, avoiding duplicate outputs.
This commit is contained in:
666ghj
2025-11-28 18:59:36 +08:00
parent 3156f9453d
commit e98da6b53e
5 changed files with 165 additions and 50 deletions

View File

@@ -31,22 +31,26 @@ def main():
port = int(os.environ.get('FLASK_PORT', 5001))
debug = Config.DEBUG
print(f"""
# 只在 reloader 子进程中打印启动信息(避免 debug 模式下打印两次)
# WERKZEUG_RUN_MAIN=true 表示当前是 reloader 启动的子进程
is_reloader_process = os.environ.get('WERKZEUG_RUN_MAIN') == 'true'
if not debug or is_reloader_process:
print(f"""
╔══════════════════════════════════════════════════╗
║ MiroFish Backend Server ║
╠══════════════════════════════════════════════════╣
║ Running on: http://{host}:{port}
║ Debug mode: {debug}
║ API Endpoints:
║ POST /api/graph/ontology/generate - 生成本体
║ POST /api/graph/build - 构建图谱
║ GET /api/graph/task/<task_id> - 查询任务
║ GET /api/graph/tasks - 列出任务
║ GET /api/graph/data/<graph_id> - 获取图数据
║ DELETE /api/graph/delete/<graph_id>- 删除图谱
║ Running on: http://{host}:{port}
║ Debug mode: {debug}
║ API Endpoints:
║ POST /api/graph/ontology/generate - 生成本体
║ POST /api/graph/build - 构建图谱
║ GET /api/graph/task/<task_id> - 查询任务
║ GET /api/graph/tasks - 列出任务
║ GET /api/graph/data/<graph_id> - 获取图数据
║ DELETE /api/graph/delete/<graph_id>- 删除图谱
╚══════════════════════════════════════════════════╝
""")
""")
# 启动服务
app.run(host=host, port=port, debug=debug, threaded=True)