fixed pipeline error
This commit is contained in:
parent
15a0061a0d
commit
56335cbfa7
2 changed files with 4 additions and 25 deletions
22
main.py
22
main.py
|
|
@ -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)
|
||||
|
|
@ -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"] == "*"
|
||||
Loading…
Add table
Reference in a new issue