Spaces:
Sleeping
Sleeping
Download app.py from cholish2026/aileaders-proxy: direct link, hf CLI and curl.
- Browser
- Download file 1.35 kB
-
https://huggingface.co/spaces/cholish2026/aileaders-proxy/resolve/main/app.py
- Command line
-
hf download hf://spaces/cholish2026/aileaders-proxy/app.py
-
curl -L -o app.py https://huggingface.co/spaces/cholish2026/aileaders-proxy/resolve/main/app.py
1.35 kB
| 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=["*"], | |
| ) | |
| 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 | |
| }) | |
| def root(): | |
| return {"status": "ok"} |