Spaces:
Paused
Paused
File size: 889 Bytes
e115727 d1e18ae e115727 d1e18ae e115727 d1e18ae e115727 | 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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | from fastapi import FastAPI
import duckdb
app = FastAPI()
# Aapke Hugging Face Dataset ka path
HF_PATH = "hf://datasets/kumarmanoj382/Inddata"
# HF parquet support
duckdb.sql("INSTALL httpfs;")
duckdb.sql("LOAD httpfs;")
@app.get("/")
def home():
return {"status": "API running"}
@app.get("/search")
def search(mobile: str):
try:
prefix = mobile[:3]
query = f"""
SELECT *
FROM read_parquet(
'{HF_PATH}/{prefix}/*.parquet',
union_by_name=True
)
WHERE mobile = '{mobile}'
"""
df = duckdb.query(query).to_df()
if df.empty:
return {
"found": 0,
"data": []
}
return {
"found": len(df),
"data": df.to_dict(orient="records")
}
except Exception as e:
return {"error": str(e)} |