Spaces:
Sleeping
Sleeping
File size: 459 Bytes
a746d34 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
from fastapi import APIRouter
from app.schemas import UserSchema
from app.models import User
from sqlalchemy.orm import sessionmaker
router = APIRouter()
@router.get("/profiles/{user_id}")
async def read_profile(user_id: int):
session = sessionmaker(bind=engine)()
user = session.query(User).filter_by(id=user_id).first()
if user is None:
raise HTTPException(status_code=404, detail="User not found")
return UserSchema.from_orm(user) |