This commit is contained in:
mzl
2026-01-12 15:49:09 +08:00
parent 7c933f4a82
commit 7c0b8c4c09
12 changed files with 383 additions and 175 deletions
+1 -1
View File
@@ -82,7 +82,7 @@ MAX_LOGS = 10000 # 最大日志条数
# ========== Web 配置 ==========
WEB_HOST = os.getenv("HOST", "0.0.0.0")
WEB_PORT = int(os.getenv("PORT", "18080")) # 默认端口 18080,范围 10000-50000
WEB_PORT = int(os.getenv("PORT", "18085")) # 默认端口 18085,范围 10000-50000
SCREENSHOT_ON_ERROR = os.getenv("SCREENSHOT_ON_ERROR", "true").lower() == "true"
# ========== Git 更新配置 ==========
+11
View File
@@ -15,6 +15,7 @@ from fastapi.templating import Jinja2Templates
from fastapi.requests import Request
from pydantic import BaseModel
from typing import List as ListType
from fastapi.middleware.cors import CORSMiddleware
from app import config
from app.log_manager import get_log_manager
@@ -61,6 +62,16 @@ log_manager = get_log_manager()
# ========== FastAPI 应用 ==========
app = FastAPI(title="小红书数据采集器", version="1.0.0")
# 添加 CORS 中间件
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # 生产环境应该指定具体域名
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
expose_headers=["*"]
)
# 挂载静态文件和模板
app.mount("/static", StaticFiles(directory="static"), name="static")
templates = Jinja2Templates(directory="templates")