-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathdebug_backend.py
More file actions
30 lines (25 loc) · 912 Bytes
/
debug_backend.py
File metadata and controls
30 lines (25 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import asyncio
import os
import sys
from pathlib import Path
# Add project root to path
sys.path.insert(0, str(Path(__file__).resolve().parent))
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
from backend.main import app
import httpx
async def test_lifespan():
logger.info("Starting lifespan test script...")
try:
async with httpx.AsyncClient(app=app, base_url="http://test") as client:
logger.info("Lifespan context entered successfully!")
response = await client.get("/health")
logger.info(f"Health check response: {response.json()}")
except Exception as e:
logger.error(f"Lifespan test failed: {e}", exc_info=True)
if __name__ == "__main__":
os.environ["ENVIRONMENT"] = "development"
os.environ["DEBUG"] = "true"
os.environ["USE_LOCAL_ML"] = "false"
asyncio.run(test_lifespan())