Spaces:
No application file
No application file
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 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 |
|
|
@@ -15,34 +16,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(...
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 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)}
|
|
|
|
| 1 |
from fastapi import FastAPI, Query
|
| 2 |
from fastapi.middleware.cors import CORSMiddleware
|
| 3 |
from datasets import load_dataset
|
| 4 |
+
import os
|
| 5 |
|
| 6 |
app = FastAPI(title="Telegram UID Search")
|
| 7 |
|
|
|
|
| 16 |
|
| 17 |
@app.get("/")
|
| 18 |
def root():
|
| 19 |
+
return {"status": "running"}
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@app.get("/search")
|
| 22 |
+
def search_uid(uid: str = Query(...)):
|
| 23 |
+
# Lazy loading — dataset sirf search ke time load hoga
|
| 24 |
+
ds = load_dataset(DATASET, split="train", streaming=True)
|
| 25 |
+
|
| 26 |
+
for row in ds:
|
| 27 |
+
if uid == str(row.get("user_id", "")):
|
| 28 |
+
return {"found": True, "data": row}
|
| 29 |
+
return {"found": False}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|