Update code in endpoints/book.post.py
This commit is contained in:
parent
1667d3e2bf
commit
972e8377b7
17
endpoints/book.post.py
Normal file
17
endpoints/book.post.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# Entity: Book
|
||||||
|
|
||||||
|
from fastapi import APIRouter, Depends, HTTPException, status
|
||||||
|
from sqlalchemy.orm import Session
|
||||||
|
from core.database import get_db
|
||||||
|
from models.book import Book
|
||||||
|
from schemas.book import BookSchema, BookCreate
|
||||||
|
from helpers.book_helpers import create_book
|
||||||
|
|
||||||
|
router = APIRouter()
|
||||||
|
|
||||||
|
@router.post("/book", status_code=201, response_model=BookSchema)
|
||||||
|
async def save_book(
|
||||||
|
book: BookCreate,
|
||||||
|
db: Session = Depends(get_db)
|
||||||
|
):
|
||||||
|
return create_book(db=db, book=book)
|
Loading…
x
Reference in New Issue
Block a user