mirror of
https://github.com/KingHWJ/WeReadBoard.git
synced 2026-11-03 18:24:58 +08:00
feat(api): 新增微信读书 v2 数据接口层
新建 api_v2.py,以独立 Flask Blueprint 挂载 /api/v2/*,与既有 /api/* 完全隔离,不影响 v1 接口。 - 提供 status / dashboard / shelf / notebooks / notes / book / reviews / highlights / underline-thoughts / thought / archives / recommend / search 等接口 - 进程内 TTL 缓存降低接口调用频次;MySQL 不可用时返回 degraded 降级标记 - 阅读状态按 finish_reading / progress / 近 30 天阅读记录综合判定 - 周月维度缺少偏好画像时回退 overall 口径补齐,并标注 preference_source - app.py 注册 Blueprint;__main__ 端口改为读取 PORT 环境变量
This commit is contained in:
1 parent
e3856ccdcf
commit
a114f3f407
2 files changed
+1686
-2
No files matched your search
@@ -27,11 +27,16 @@ from functools import wraps
|
||||
import pymysql
|
||||
from flask import Flask, jsonify, render_template, request
|
||||
|
||||
from api_v2 import v2_bp
|
||||
|
||||
# ======================================================================
|
||||
# Flask 应用实例
|
||||
# ======================================================================
|
||||
app = Flask(__name__, static_folder="static", template_folder="templates")
|
||||
|
||||
# 注册 v2 数据接口(/api/v2/*,为「阅间」新版前端提供聚合数据)
|
||||
app.register_blueprint(v2_bp)
|
||||
|
||||
# ======================================================================
|
||||
# 数据库连接配置
|
||||
# ======================================================================
|
||||
@@ -1270,5 +1275,7 @@ if __name__ == "__main__":
|
||||
else:
|
||||
print(f"[信息] {msg}")
|
||||
|
||||
# 启动 Flask 服务,监听 8080 端口
|
||||
app.run(host="0.0.0.0", port=8080, debug=False)
|
||||
# 监听端口:默认 8080,可用环境变量 PORT 覆盖(v2 前端与 v1 并存时可换端口)
|
||||
port = int(os.environ.get("PORT", 8080))
|
||||
print(f"[信息] 打开 http://127.0.0.1:{port} 查看「阅间」看板")
|
||||
app.run(host="0.0.0.0", port=port, debug=False)
|
||||
Reference in new issue
Block a user