mirror of
https://github.com/LifeArchiveProject/WeChatDataAnalysis.git
synced 2026-02-02 05:50:50 +08:00
- 若存在 WECHAT_TOOL_UI_DIR 或 frontend/.output/public,则在 / 挂载静态站点并支持 SPA 路由回退 - API 根端点调整为 /api,避免与静态 UI 冲突 - 新增 WECHAT_TOOL_DATA_DIR 输出目录约定,统一 databases/key store 等路径 - host/port 支持通过 WECHAT_TOOL_HOST / WECHAT_TOOL_PORT 配置,并打印可访问地址 - 新增 backend_entry.py 作为 PyInstaller 入口,减少动态导入识别问题
53 lines
1.3 KiB
Python
53 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
微信解密工具主启动脚本
|
|
|
|
使用方法:
|
|
uv run main.py
|
|
|
|
默认在8000端口启动API服务
|
|
"""
|
|
|
|
import uvicorn
|
|
import os
|
|
from pathlib import Path
|
|
|
|
def main():
|
|
"""启动微信解密工具API服务"""
|
|
host = os.environ.get("WECHAT_TOOL_HOST", "127.0.0.1")
|
|
port = int(os.environ.get("WECHAT_TOOL_PORT", "8000"))
|
|
access_host = "127.0.0.1" if host in {"0.0.0.0", "::"} else host
|
|
|
|
print("=" * 60)
|
|
print("微信解密工具 API 服务")
|
|
print("=" * 60)
|
|
print("正在启动服务...")
|
|
print(f"API文档: http://{access_host}:{port}/docs")
|
|
print(f"健康检查: http://{access_host}:{port}/api/health")
|
|
print("按 Ctrl+C 停止服务")
|
|
print("=" * 60)
|
|
|
|
repo_root = Path(__file__).resolve().parent
|
|
enable_reload = os.environ.get("WECHAT_TOOL_RELOAD", "0") == "1"
|
|
|
|
# 启动API服务
|
|
uvicorn.run(
|
|
"wechat_decrypt_tool.api:app",
|
|
host=host,
|
|
port=port,
|
|
reload=enable_reload,
|
|
reload_dirs=[str(repo_root / "src")] if enable_reload else None,
|
|
reload_excludes=[
|
|
"output/*",
|
|
"output/**",
|
|
"frontend/*",
|
|
"frontend/**",
|
|
".venv/*",
|
|
".venv/**",
|
|
] if enable_reload else None,
|
|
log_level="info"
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|