jdeip/app/routers/proxy.py
2025-10-21 18:41:07 +08:00

34 lines
668 B
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.

from typing import Optional
from fastapi import APIRouter, Body, Query, Form,Request
from pydantic import BaseModel
from ..rotation_service import rotate as rotate_impl, status as status_impl
router = APIRouter()
class RotateRequest(BaseModel):
cityhash: Optional[str] = None
num: Optional[int] = None
@router.post("/rotate")
def rotate(
req: Optional[RotateRequest] = Body(...),
):
# 优先级Query > Form > JSON
client_id = req.id
# effective_cityhash = req.cityhash
# effective_num = req.num
result = rotate_impl(client_id=client_id)
return result
@router.get("/status")
def get_status():
return status_impl()