from fastapi import FastAPI, Request from fastapi.middleware.cors import CORSMiddleware from fastapi.responses import JSONResponse import httpx app = FastAPI() app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_methods=["*"], allow_headers=["*"], ) @app.post("/check") async def check(request: Request): body = await request.json() pinfl = body.get("pinfl") cookies = body.get("cookies", {}) cookie_str = "; ".join([f"{k}={v}" for k, v in cookies.items()]) async with httpx.AsyncClient(follow_redirects=True) as client: resp = await client.get( f"https://aileaders.uz/certificates?pinfl={pinfl}", headers={ "cookie": cookie_str, "accept": "application/json, text/plain, */*", "referer": "https://aileaders.uz/auth/login/check", "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36", "x-requested-with": "XMLHttpRequest", }, timeout=20 ) try: data = resp.json() except: data = {"raw": resp.text[:500]} return JSONResponse(content={ "status": resp.status_code, "data": data }) @app.get("/") def root(): return {"status": "ok"}