File size: 547 Bytes
c81f3a9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
from fastapi import APIRouter, Depends, HTTPException
from fastapi.security import OAuth2PasswordBearer
from sqlalchemy.orm import Session
from app.database import get_db
from app.models import User
router = APIRouter()
# Define specific routes and request handlers
@router.get("/user/{user_id}", response_model=User)
def read_user(user_id: int, db: Session = Depends(get_db)):
user = db.query(User).filter(User.id == user_id).first()
if user is None:
raise HTTPException(status_code=404, detail="User not found")
return user |