Spaces:
Sleeping
Sleeping
| import logging | |
| import asyncio | |
| from fastapi import FastAPI, Request | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from fastapi.responses import JSONResponse | |
| import uvicorn | |
| # Configure logging | |
| logging.basicConfig( | |
| level=logging.INFO, | |
| format='%(asctime)s - %(name)s - %(levelname)s - %(message)s' | |
| ) | |
| logger = logging.getLogger(__name__) | |
| app = FastAPI() | |
| # Add CORS middleware | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=["*"], | |
| allow_credentials=True, | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| # Simple health check endpoint | |
| async def healthcheck(): | |
| return {"status": "ok"} | |
| # Test endpoint that doesn't use any external services | |
| async def test_endpoint(): | |
| return {"message": "Test endpoint working"} | |
| # Test endpoint that simulates a delay | |
| async def test_delay(seconds: float = 2.0): | |
| await asyncio.sleep(seconds) | |
| return {"message": f"Delayed response after {seconds} seconds"} | |
| if __name__ == "__main__": | |
| uvicorn.run( | |
| "debug_main:app", | |
| host="0.0.0.0", | |
| port=8000, | |
| reload=True, | |
| log_level="info" | |
| ) | |