Spaces:
Running
Running
Commit ·
78968ef
1
Parent(s): 6fd8298
fix(api): add Neo4j connection debug endpoint
Browse files- api/main.py +15 -0
api/main.py
CHANGED
|
@@ -114,3 +114,18 @@ def debug_env():
|
|
| 114 |
"neo4j_password_set": bool(os.getenv("NEO4J_PASSWORD")),
|
| 115 |
"neo4j_uri_prefix": (os.getenv("NEO4J_URI","")[:15] + "...") if os.getenv("NEO4J_URI") else "NOT SET",
|
| 116 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
"neo4j_password_set": bool(os.getenv("NEO4J_PASSWORD")),
|
| 115 |
"neo4j_uri_prefix": (os.getenv("NEO4J_URI","")[:15] + "...") if os.getenv("NEO4J_URI") else "NOT SET",
|
| 116 |
}
|
| 117 |
+
|
| 118 |
+
@app.get("/debug/neo4j")
|
| 119 |
+
def debug_neo4j():
|
| 120 |
+
import os
|
| 121 |
+
from neo4j import GraphDatabase
|
| 122 |
+
uri = os.getenv("NEO4J_URI", "")
|
| 123 |
+
user = os.getenv("NEO4J_USER", "neo4j")
|
| 124 |
+
password = os.getenv("NEO4J_PASSWORD", "")
|
| 125 |
+
try:
|
| 126 |
+
driver = GraphDatabase.driver(uri, auth=(user, password))
|
| 127 |
+
driver.verify_connectivity()
|
| 128 |
+
driver.close()
|
| 129 |
+
return {"status": "connected", "uri_prefix": uri[:20]}
|
| 130 |
+
except Exception as e:
|
| 131 |
+
return {"status": "failed", "error": str(e), "uri_prefix": uri[:20]}
|