Spaces:
Running
Running
Aryan Pachani commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,25 +25,25 @@ app = FastAPI(title="Super Fast Search API", lifespan=lifespan)
|
|
| 25 |
|
| 26 |
@app.get("/")
|
| 27 |
def home():
|
| 28 |
-
return {"message": "Fast API online hai! Use /search?
|
| 29 |
|
| 30 |
@app.get("/search")
|
| 31 |
-
async def
|
| 32 |
try:
|
| 33 |
# Ab hum direct cache kiye hue 'users_view' se data nikalenge
|
| 34 |
query = """
|
| 35 |
SELECT mobile, name, fname, address, alt, circle, id, email
|
| 36 |
FROM users_view
|
| 37 |
-
WHERE
|
| 38 |
-
LIMIT
|
| 39 |
"""
|
| 40 |
|
| 41 |
-
result = con.execute(query, [str(
|
| 42 |
|
| 43 |
if not result:
|
| 44 |
return {
|
| 45 |
"status": "error",
|
| 46 |
-
"message": f"
|
| 47 |
}
|
| 48 |
|
| 49 |
# Data mapping
|
|
|
|
| 25 |
|
| 26 |
@app.get("/")
|
| 27 |
def home():
|
| 28 |
+
return {"message": "Fast API online hai! Use /search?mobile=YOUR_NUMBER"}
|
| 29 |
|
| 30 |
@app.get("/search")
|
| 31 |
+
async def search_mobile(mobile: str = Query(..., description="Enter mobile number to search")):
|
| 32 |
try:
|
| 33 |
# Ab hum direct cache kiye hue 'users_view' se data nikalenge
|
| 34 |
query = """
|
| 35 |
SELECT mobile, name, fname, address, alt, circle, id, email
|
| 36 |
FROM users_view
|
| 37 |
+
WHERE mobile = ?
|
| 38 |
+
LIMIT 1
|
| 39 |
"""
|
| 40 |
|
| 41 |
+
result = con.execute(query, [str(mobile)]).fetchall()
|
| 42 |
|
| 43 |
if not result:
|
| 44 |
return {
|
| 45 |
"status": "error",
|
| 46 |
+
"message": f"Mobile number {mobile} nahi mila."
|
| 47 |
}
|
| 48 |
|
| 49 |
# Data mapping
|