Spaces:
Sleeping
Sleeping
surbi karki commited on
Update main.py
Browse files
main.py
CHANGED
|
@@ -174,6 +174,24 @@ def trigger_ingestion():
|
|
| 174 |
logger.error(f"Ingestion error: {e}")
|
| 175 |
raise HTTPException(status_code=500, detail=str(e))
|
| 176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
if __name__ == "__main__":
|
| 178 |
import uvicorn
|
| 179 |
uvicorn.run(app, host="0.0.0.0", port=8000)
|
|
|
|
| 174 |
logger.error(f"Ingestion error: {e}")
|
| 175 |
raise HTTPException(status_code=500, detail=str(e))
|
| 176 |
|
| 177 |
+
@app.get("/api/pubmed/search")
|
| 178 |
+
def search_pubmed(query: str = "postpartum depression", limit: int = 10):
|
| 179 |
+
"""
|
| 180 |
+
Real-time proxy to PubMed API.
|
| 181 |
+
Used by frontend to fetch fresh articles on demand.
|
| 182 |
+
"""
|
| 183 |
+
try:
|
| 184 |
+
service = IngestionService()
|
| 185 |
+
results = service.fetch_from_pubmed(query, limit)
|
| 186 |
+
return {
|
| 187 |
+
"status": "success",
|
| 188 |
+
"count": len(results),
|
| 189 |
+
"results": results
|
| 190 |
+
}
|
| 191 |
+
except Exception as e:
|
| 192 |
+
logger.error(f"PubMed search error: {e}")
|
| 193 |
+
raise HTTPException(status_code=503, detail="PubMed service unavailable")
|
| 194 |
+
|
| 195 |
if __name__ == "__main__":
|
| 196 |
import uvicorn
|
| 197 |
uvicorn.run(app, host="0.0.0.0", port=8000)
|