Spaces:
No application file
No application file
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,41 +1,48 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
from datasets import load_dataset
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
DATASET = "CodeXDevloper/MergedTgDataset"
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
try:
|
| 11 |
ds = load_dataset(DATASET, split="train", streaming=True)
|
| 12 |
|
|
|
|
| 13 |
for row in ds:
|
|
|
|
| 14 |
if uid == str(row.get("user_id", "")).strip():
|
| 15 |
return {
|
| 16 |
"found": True,
|
| 17 |
-
"
|
| 18 |
-
"
|
| 19 |
-
"
|
| 20 |
-
"last_name": row.get("last_name"),
|
| 21 |
-
"phone": row.get("phone"),
|
| 22 |
-
"email": row.get("email"),
|
| 23 |
-
"status": row.get("status"),
|
| 24 |
-
"linked_id": row.get("linked_id"),
|
| 25 |
-
"linked_name": row.get("linked_name"),
|
| 26 |
-
"linked_handle": row.get("linked_handle"),
|
| 27 |
}
|
|
|
|
|
|
|
| 28 |
|
| 29 |
-
return {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
except Exception as e:
|
| 31 |
-
return {"error": str(e)}
|
| 32 |
-
|
| 33 |
-
demo = gr.Interface(
|
| 34 |
-
fn=search_uid,
|
| 35 |
-
inputs=gr.Textbox(label="UID daalo", placeholder="385167100"),
|
| 36 |
-
outputs=gr.JSON(label="Result"),
|
| 37 |
-
title="Telegram UID Search",
|
| 38 |
-
description="UID daal ke poore dataset mein search karo"
|
| 39 |
-
)
|
| 40 |
-
|
| 41 |
-
demo.launch()
|
|
|
|
| 1 |
+
from fastapi import FastAPI, Query
|
| 2 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 3 |
from datasets import load_dataset
|
| 4 |
|
| 5 |
+
app = FastAPI(title="Telegram UID Search")
|
| 6 |
+
|
| 7 |
+
app.add_middleware(
|
| 8 |
+
CORSMiddleware,
|
| 9 |
+
allow_origins=["*"],
|
| 10 |
+
allow_methods=["*"],
|
| 11 |
+
allow_headers=["*"],
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
DATASET = "CodeXDevloper/MergedTgDataset"
|
| 15 |
|
| 16 |
+
@app.get("/")
|
| 17 |
+
def root():
|
| 18 |
+
return {
|
| 19 |
+
"status": "running",
|
| 20 |
+
"usage": "/search?uid=385167100"
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
@app.get("/search")
|
| 24 |
+
def search_uid(uid: str = Query(..., description="Telegram UID")):
|
| 25 |
try:
|
| 26 |
ds = load_dataset(DATASET, split="train", streaming=True)
|
| 27 |
|
| 28 |
+
scanned = 0
|
| 29 |
for row in ds:
|
| 30 |
+
scanned += 1
|
| 31 |
if uid == str(row.get("user_id", "")).strip():
|
| 32 |
return {
|
| 33 |
"found": True,
|
| 34 |
+
"uid": uid,
|
| 35 |
+
"scanned": scanned,
|
| 36 |
+
"data": row
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
}
|
| 38 |
+
if scanned >= 5000000: # 50 lakh rows tak
|
| 39 |
+
break
|
| 40 |
|
| 41 |
+
return {
|
| 42 |
+
"found": False,
|
| 43 |
+
"uid": uid,
|
| 44 |
+
"scanned": scanned,
|
| 45 |
+
"message": f"UID '{uid}' nahi mila"
|
| 46 |
+
}
|
| 47 |
except Exception as e:
|
| 48 |
+
return {"error": str(e)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|