Skip to content

文件:main.py ​

负责应用装配与路由挂载。

函数定义与行为 ​

create_app() -> FastAPI ​

根静态资源(可选)

  • 若存在根目录 static/:static/index.html 挂到 /,并把 static/ 下其他文件名挂到 /<filename>。

关卡加载

  • 读取 map_levels()。
  • 跳过 enabled=false 的关卡。
  • import levels.<module>。
  • 注入关卡索引:set_level_index() 优先,否则赋值 CURRENT_LEVEL_INDEX。
  • 挂载 API:/api/{slug},并附加 Depends(check_level_permission(idx))。
  • 若存在 levels/<module>/static,挂载到 /{slug}。

服务加载

  • 读取 map_services()。
  • 跳过 enabled=false 的服务。
  • import services.<module>。
  • 挂载 API:/services/{slug}。

健康检查

  • GET /health 返回 { "status": "ok" }。