federation-bridge / preflight.py
Kode-Animator's picture
Fix: Add proxy headers and host binding for FastMCP
b5e0c5c
Raw
History Blame Contribute Delete
1.95 kB
import asyncio
import httpx
async def check():
print("="*50)
print("LIVE ENVIRONMENT PREFLIGHT CHECK")
print("="*50)
try:
print("\nChecking Node (kode-animator-federation-node.hf.space)...")
async with httpx.AsyncClient(timeout=10.0) as c:
r = await c.get("https://kode-animator-federation-node.hf.space/")
r.raise_for_status()
data = r.json()
print("🟒 Node is UP")
print(f" Identity: {data.get('identity')}")
print(f" Status: {data.get('status')}")
except Exception as e:
print(f"πŸ”΄ Node check failed: {e}")
try:
print("\nChecking Bridge (kode-animator-federation-bridge.hf.space)...")
async with httpx.AsyncClient(timeout=10.0) as c:
r = await c.get("https://kode-animator-federation-bridge.hf.space/")
r.raise_for_status()
data = r.json()
print("🟒 Bridge is UP")
print(f" Service: {data.get('service')}")
print(f" Target Node config: {data.get('bridge_target_node')}")
print("\nChecking Bridge /sse endpoint...")
async with httpx.AsyncClient(timeout=10.0) as c:
# We just do a HEAD or GET expecting an SSE stream or 422/Method Not Allowed/etc
r = await c.get("https://kode-animator-federation-bridge.hf.space/sse")
# Usually SSE endpoint might wait forever, but we can check status
print(f"🟒 Bridge /sse endpoint returned status: {r.status_code}")
except httpx.HTTPStatusError as e:
print(f"πŸ”΄ Bridge check HTTP error: {e.response.status_code}")
print(f" Response: {e.response.text[:200]}")
except httpx.ReadTimeout:
print("🟒 Bridge /sse is waiting for connection (Timeout as expected for SSE stream)")
except Exception as e:
print(f"πŸ”΄ Bridge check failed: {e}")
asyncio.run(check())