Files
outlookEmailPlus/web_outlook_app.py
T
胡绍康andCopilot c70d2b97dd chore: 代码质量修复 + CI升级
- black 格式化 (1 file)
- isort 排序修复 (30 files, --profile black)
- 升级 actions/checkout v4 → v6 (全部 3 个 workflow)
- 添加 pyproject.toml (black/isort 配置)
- isort CI 命令添加 --profile black 参数
- 114 测试全部通过

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-01 21:52:44 +08:00

70 lines
2.2 KiB
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.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Outlook 邮件 Web 应用(兼容入口)
目标:
- 保持部署入口兼容:`web_outlook_app:app`
- 内部实现已迁移到 `outlook_web/` 模块化架构
关联文档:
- PRD:docs/PRD/Outlook邮件管理工具-前后端拆分与模块化PRD.md
- FD:docs/FD/Outlook邮件管理工具-前后端拆分与模块化FD.md
- TDD:docs/TDD/Outlook邮件管理工具-前后端拆分与模块化TDD.md
- DEV:docs/DEV/00002-前后端拆分-开发者指南.md
"""
import os
from outlook_web.app import create_app
from outlook_web.db import create_sqlite_connection
from outlook_web.errors import build_error_payload, sanitize_error_details
from outlook_web.repositories.distributed_locks import (
acquire_distributed_lock,
release_distributed_lock,
)
# 兼容导入:从各模块导出常用函数
from outlook_web.security.auth import MAX_LOGIN_ATTEMPTS
from outlook_web.security.crypto import decrypt_data, encrypt_data
from outlook_web.services import graph as graph_service
from outlook_web.services import scheduler as scheduler_service
# 在脚本运行场景(__main__)中,调度器由 main block 统一控制,
# 避免 debug reloader 父进程误启后台线程。
app = create_app(autostart_scheduler=None if __name__ != "__main__" else False)
__all__ = [
"app",
"create_sqlite_connection",
"MAX_LOGIN_ATTEMPTS",
"sanitize_error_details",
"build_error_payload",
"decrypt_data",
"encrypt_data",
"acquire_distributed_lock",
"release_distributed_lock",
]
if __name__ == "__main__":
port = int(os.getenv("PORT", 5000))
host = os.getenv("HOST", "0.0.0.0")
debug = os.getenv("FLASK_ENV", "production") != "production"
print("=" * 60)
print("Outlook 邮件 Web 应用")
print("=" * 60)
print(f"访问地址: http://{host}:{port}")
print(f"运行模式: {'开发' if debug else '生产'}")
print("=" * 60)
# 初始化定时任务(与旧版行为保持一致)
if not debug or os.getenv("WERKZEUG_RUN_MAIN") == "true":
scheduler_service.init_scheduler(app, graph_service.test_refresh_token)
else:
print("✓ 调试重载器父进程:跳过启动调度器")
app.run(debug=debug, host=host, port=port)