Aryan Pachani commited on
Commit
487e6cc
·
verified ·
1 Parent(s): c660009

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
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?id=YOUR_ID"}
29
 
30
  @app.get("/search")
31
- async def search_by_id(id: str = Query(..., description="Enter ID 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 id = ?
38
- LIMIT 5
39
  """
40
 
41
- result = con.execute(query, [str(id)]).fetchall()
42
 
43
  if not result:
44
  return {
45
  "status": "error",
46
- "message": f"ID {id} nahi mila."
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