Spaces:
Sleeping
Sleeping
Update main.py
Browse files
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(
|
| 61 |
-
|
| 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(
|
| 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
|