video-accessibility/backend/test_endpoint.py
2025-08-24 16:28:33 -05:00

30 lines
No EOL
1,015 B
Python

#!/usr/bin/env python3
"""Add a simple test endpoint to debug the issue."""
from fastapi import FastAPI, Depends
from motor.motor_asyncio import AsyncIOMotorDatabase
from app.core.database import get_database
app = FastAPI()
@app.post("/test-db")
async def test_db_endpoint(db: AsyncIOMotorDatabase = Depends(get_database)):
"""Test database dependency injection."""
try:
print("1. Inside test endpoint")
user_count = await db.users.count_documents({})
print(f"2. User count: {user_count}")
return {"status": "success", "user_count": user_count}
except Exception as e:
print(f"3. Error: {e}")
return {"status": "error", "message": str(e)}
@app.post("/test-simple")
async def test_simple_endpoint():
"""Test simple endpoint without dependencies."""
print("Simple endpoint called")
return {"status": "success", "message": "Simple endpoint works"}
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8001)