您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

route_user.py 497 B

1234567891011121314151617
  1. # Routes for user. MAIN PART OF THE API
  2. from fastapi import APIRouter, status
  3. from sqlalchemy.orm import Session
  4. from fastapi import Depends
  5. from schemas.user import UserCreate, ShowUser
  6. from db.session import get_db
  7. from db.repository.user import create_new_user
  8. router = APIRouter()
  9. @router.post("/", response_model=ShowUser, status_code=status.HTTP_201_CREATED)
  10. def create_user(user: UserCreate, db: Session = Depends(get_db)):
  11. user = create_new_user(user=user, db=db)
  12. return user