2025-10-21 20:04:19 +08:00
|
|
|
from fastapi import FastAPI, Request
|
|
|
|
|
from fastapi.templating import Jinja2Templates
|
|
|
|
|
from fastapi.staticfiles import StaticFiles
|
|
|
|
|
from fastapi.responses import HTMLResponse
|
2025-10-17 17:17:14 +08:00
|
|
|
from .config import settings
|
|
|
|
|
from .routers.proxy import router as proxy_router
|
|
|
|
|
|
|
|
|
|
app = FastAPI(title="EIP Rotation Service")
|
|
|
|
|
|
2025-10-21 20:04:19 +08:00
|
|
|
# 设置模板目录
|
|
|
|
|
templates = Jinja2Templates(directory="app/templates")
|
|
|
|
|
|
2025-10-17 17:17:14 +08:00
|
|
|
|
|
|
|
|
@app.get("/health")
|
|
|
|
|
def health_check():
|
|
|
|
|
return {"status": "ok"}
|
|
|
|
|
|
|
|
|
|
|
2025-10-21 20:04:19 +08:00
|
|
|
@app.get("/", response_class=HTMLResponse)
|
|
|
|
|
async def index(request: Request, id: str = None):
|
|
|
|
|
"""主页 - IP轮换控制面板"""
|
|
|
|
|
return templates.TemplateResponse("index.html", {
|
|
|
|
|
"request": request,
|
|
|
|
|
"client_id": id or "1" # 默认ID为1
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
2025-10-17 17:17:14 +08:00
|
|
|
app.include_router(proxy_router, prefix="/proxy", tags=["proxy"])
|
|
|
|
|
|
|
|
|
|
|