fixed pipeline error

This commit is contained in:
Utsho Dey 2024-12-18 13:16:48 +06:00
parent 15a0061a0d
commit 56335cbfa7
2 changed files with 4 additions and 25 deletions

24
main.py
View file

@ -11,46 +11,28 @@ app = FastAPI(
)
# CORS configuration
origins = [
FRONTEND_URL,
"http://localhost",
"http://localhost:5173",
"http://0.0.0.0",
"http://0.0.0.0:5173",
"*"
]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_origins=["*"], # Only wildcard
allow_credentials=False, # Changed to False to work with wildcard
allow_methods=["*"],
allow_headers=["*"],
)
# Basic root endpoint
@app.get("/")
async def root():
return {"message": "Welcome to your FastAPI application"}
# Health check endpoint
@app.get("/health")
async def health_check():
return {"status": "healthy"}
app.include_router(fact_check_router, prefix="")
app.include_router(aifact_check_router, prefix="")
app.include_router(scrap_websites_router, prefix="")
# Include routers (uncomment and modify as needed)
# from routes import some_router
# app.include_router(some_router, prefix="/your-prefix", tags=["your-tag"])
if __name__ == "__main__":
import uvicorn
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)

View file

@ -3,19 +3,16 @@ from main import app
client = TestClient(app)
def test_root_endpoint():
response = client.get("/")
assert response.status_code == 200
assert response.json() == {"message": "Welcome to your FastAPI application"}
def test_health_endpoint():
response = client.get("/health")
assert response.status_code == 200
assert response.json() == {"status": "healthy"}
def test_cors_headers():
response = client.get("/", headers={"Origin": "http://localhost:5173"})
assert response.headers["access-control-allow-origin"] == "http://localhost:5173"
assert response.headers["access-control-allow-origin"] == "*"