HiTeckGroup commited on
Commit
a6c088f
·
verified ·
1 Parent(s): 34c4e5b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -1
app.py CHANGED
@@ -1 +1,44 @@
1
- .
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ import duckdb
3
+ import traceback
4
+
5
+ app = FastAPI()
6
+
7
+ # 93 GB ki file ka path
8
+ HF_FILE = "hf://datasets/HiTeckGroup/HiTeckNuMinfoo@main/users_data.parquet"
9
+ con = duckdb.connect()
10
+
11
+ @app.on_event("startup")
12
+ def startup():
13
+ con.execute("INSTALL httpfs;")
14
+ con.execute("LOAD httpfs;")
15
+
16
+ @app.get("/email")
17
+ def search_email(email: str):
18
+ try:
19
+ # Email se search karne ke liye query
20
+ # Dhyan rahe: Agar email column sorted nahi hai, toh ye 30s se upar le sakta hai
21
+ query = """
22
+ SELECT *
23
+ FROM read_parquet(?)
24
+ WHERE email = ?
25
+ LIMIT 10
26
+ """
27
+
28
+ df = con.execute(query, [HF_FILE, email]).fetchdf()
29
+
30
+ if df.empty:
31
+ return {"found": 0, "data": []}
32
+
33
+ return {
34
+ "found": len(df),
35
+ "data": df.to_dict(orient="records")
36
+ }
37
+
38
+ except Exception as e:
39
+ return {"error": str(e)}
40
+
41
+ @app.get("/")
42
+ def home():
43
+ return {"status": "API
44
+ active"}