shreyankisiri commited on
Commit
41cb8ee
·
verified ·
1 Parent(s): 0f6b22c

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +4 -7
main.py CHANGED
@@ -55,18 +55,15 @@ def find_similar_courses(query_text):
55
  @app.get("/health")
56
  async def health():
57
  return {"status": "OK"}
58
-
59
  @app.post("/search")
60
- async def search(request: Request):
61
- body = await request.json() # Get the JSON body of the request
62
- query_text = body.get("query") # Extract the 'query' field from the body
63
-
64
- if not query_text:
65
  return {"error": "Query parameter is required."}
66
 
67
- top_courses = find_similar_courses(query_text)
68
  return [course["course_id"] for course in top_courses]
69
 
 
70
  if __name__ == "__main__":
71
  import uvicorn
72
  uvicorn.run(app, host="0.0.0.0", port=7860) # Hugging Face requires port 7860
 
55
  @app.get("/health")
56
  async def health():
57
  return {"status": "OK"}
 
58
  @app.post("/search")
59
+ async def search(query: str): # Accept `query` directly as a parameter
60
+ if not query:
 
 
 
61
  return {"error": "Query parameter is required."}
62
 
63
+ top_courses = find_similar_courses(query)
64
  return [course["course_id"] for course in top_courses]
65
 
66
+
67
  if __name__ == "__main__":
68
  import uvicorn
69
  uvicorn.run(app, host="0.0.0.0", port=7860) # Hugging Face requires port 7860