20 lines
571 B
Python
20 lines
571 B
Python
from fastapi import FastAPI, Depends, HTTPException
|
|
from sqlalchemy.orm import Session
|
|
from sqlalchemy import text
|
|
from app.database import get_db
|
|
|
|
app = FastAPI(title="Card Game Backend")
|
|
|
|
@app.get("/health")
|
|
def health_check():
|
|
return {"status": "ok"}
|
|
|
|
@app.get("/db-check")
|
|
def db_check(db: Session = Depends(get_db)):
|
|
try:
|
|
# Execute simple query to check connection
|
|
db.execute(text("SELECT 1"))
|
|
return {"db": "ok"}
|
|
except Exception as e:
|
|
raise HTTPException(status_code=500, detail=f"Database connection failed: {str(e)}")
|