Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -57,8 +57,14 @@ async def health():
|
|
| 57 |
return {"status": "OK"}
|
| 58 |
|
| 59 |
@app.post("/search")
|
| 60 |
-
async def search(request:
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
return [course["course_id"] for course in top_courses]
|
| 63 |
|
| 64 |
if __name__ == "__main__":
|
|
|
|
| 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__":
|