This project is a simple Book Management API built with Python and FastAPI.
-
GET /books
: This endpoint is used to get a list of all books in the database. -
GET /books/{id}
: This endpoint is used to get a single book by its ID. -
POST /books
: This endpoint is used to create a new book. It accepts a JSON body with the book details and returns a list of all books in the database, including the newly created one.
To create a new book, send a POST request to /books
with the following JSON body:
{
"title": "Book Title",
"author": "Author Name",
"year_of_publication": "Year of Publication",
"review": "Book Review"
}
To run the project locally, you will need Python and FastAPI installed. Then, you can run the server with the following command:
uvicorn main:app --reload
This will start the server on http://localhost:8000.
To run the tests, you will need to install pytest. Then, you can run the tests with the following command:
pytest
Contributions are welcome! Feel free to open an issue or submit a pull request if you have a suggestion.
This project is licensed under the MIT License.