Spaces:
No application file
No application file
File size: 724 Bytes
845622f 413cf70 7ea09ac 3537f59 845622f 413cf70 3537f59 845622f 7ea09ac 845622f 7ea09ac | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | from fastapi import FastAPI, Query
from fastapi.middleware.cors import CORSMiddleware
from datasets import load_dataset
import os
app = FastAPI(title="Telegram UID Search")
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_methods=["*"],
allow_headers=["*"],
)
DATASET = "CodeXDevloper/MergedTgDataset"
@app.get("/")
def root():
return {"status": "running"}
@app.get("/search")
def search_uid(uid: str = Query(...)):
# Lazy loading — dataset sirf search ke time load hoga
ds = load_dataset(DATASET, split="train", streaming=True)
for row in ds:
if uid == str(row.get("user_id", "")):
return {"found": True, "data": row}
return {"found": False} |