Files
hello_js_reverse_skill/tcaptcha/web/__init__.py
T
yml2213 99565f65f0 feat(web): 新增 Web 观测台(形态 A)+ 抽出 render/targets 共用层
- tcaptcha/web/:FastAPI + SSE + 零构建单页。把同步阻塞的 solve() 包成可观测
  后台任务(工作线程 + 全局串行,因 onnxruntime session 非线程安全),用
  logging.Handler 零侵入把 client 日志变成事件流;按靶子实测 min_interval 强制节流。
- tcaptcha/render.py:标注图(点击顺序编号 + 质心偏差)与点位量尺,CLI 与 web 共用。
- tcaptcha/targets.py:靶子表提为单一来源(含实测频控间隔 1ms=60s / mliev=3s)。
- fastapi/uvicorn 走 optional extra `web`,核心包零 web 依赖(带回归断言)。
- 修两个真 bug:hook 求解器时 args[0] 是实例自身(真入参从 args[1] 起);
  client 默认每次新建 solver,预热实例未被复用(每发重载 56MB ONNX)。
- 复验:icon/text/slider 三题型各拿到 errorCode=0;selftest 全绿;依赖隔离通过。

用法:uv run --extra web python -m tcaptcha.web.app
2026-10-14 19:10:54 +08:00

20 lines
887 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""Web 观测台(形态 A:观测 / 调试台)。
分层:
* `events.py` 事件模型(前后端共用同一套 `EVT_*` 类型名)
* `runner.py` `SolveJob` / `JobManager` —— 把同步阻塞的 `solve()` 包成
"可观测的后台任务"(工作线程 + 全局串行 + 频控节流 + 事件化)
* `app.py` FastAPI 路由(建任务 / SSE / 图片 / 快照 / 取消)
* `static/` 零构建单页(原生 JS,不引打包器/框架)
**依赖是可选 extra**:`fastapi` + `uvicorn` 装在 `[project.optional-dependencies].web`,
核心包(协议 / 遥测 / 求解器 / CLI)完全不依赖它们 —— 所以本模块的 `__init__`
刻意**不 import app**,避免 `import tcaptcha.web` 就把 fastapi 拉进来。
启动:
uv run --extra web python -m tcaptcha.web.app
"""
__all__: list = []