Files
microfish/backend/run.py
Kunthawat Greethong 596a75c229 Phase 1+2: Rename CrowdSight + fix Thai vocabulary
Phase 1: Rename MiroFish → CrowdSight across all files
- 39 files, 114+ occurrences replaced
- Frontend, backend, locales, config, README, docker-compose

Phase 2: Fix difficult Thai vocabulary
- เมล็ดพันธุ์แห่งความจริง → ข้อมูลตั้งต้น
- สกัดเอนทิตี → ดึงตัวละคร
- ฉีดความจำ → เพิ่มความจำ
- ออนโทโลยี → โครงสร้างข้อมูล
- เอนทิตี → ตัวละคร
- พลวัตกลุ่ม → พฤติกรรมกลุ่ม
- โลกคู่ขนาน → โลกจำลอง

Only string changes, no logic changes.
2026-06-26 10:27:48 +07:00

51 lines
1.3 KiB
Python

"""
CrowdSight Backend 启动入口
"""
import os
import sys
# 解决 Windows 控制台中文乱码问题:在所有导入之前设置 UTF-8 编码
if sys.platform == 'win32':
# 设置环境变量确保 Python 使用 UTF-8
os.environ.setdefault('PYTHONIOENCODING', 'utf-8')
# 重新配置标准输出流为 UTF-8
if hasattr(sys.stdout, 'reconfigure'):
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
if hasattr(sys.stderr, 'reconfigure'):
sys.stderr.reconfigure(encoding='utf-8', errors='replace')
# 添加项目根目录到路径
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from app import create_app
from app.config import Config
def main():
"""主函数"""
# 验证配置
errors = Config.validate()
if errors:
print("配置错误:")
for err in errors:
print(f" - {err}")
print("\n请检查 .env 文件中的配置")
sys.exit(1)
# 创建应用
app = create_app()
# 获取运行配置
host = os.environ.get('FLASK_HOST', '0.0.0.0')
port = int(os.environ.get('FLASK_PORT', 5001))
debug = Config.DEBUG
# 启动服务
app.run(host=host, port=port, debug=debug, threaded=True)
if __name__ == '__main__':
main()