8000 GitHub - Leny73/Bookshelf: Back-end Application developed in Python and SQLAlchemy with a RESTful API, Unit Tests and API tests
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Back-end Application developed in Python and SQLAlchemy with a RESTful API, Unit Tests and API tests

Notifications You must be signed in to change notification settings

Leny73/Bookshelf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bookshelf App

Back-end Application developed in Python using Flask, SQLAlchemy with a RESTful API, Unit Tests and API tests for Udacity Course in API Development and Documentation

Getting Started

This is a simple Back-End application to store Books. To run API tests just run test_flaskr.py file with python. Example: python3 test_flaskr.py To start the application clone the Github repository. Open the project directory and set up Flask environment in a terminal execute the following commands:
export FLASK_ENV = development export FLASK_APP = flaskr
flask run

Make sure you have flask installed to be able to host this project locally. After typing this into terminal you should be running the flask app on port http://127.0.0.1:5000/ and see a message in the terminal:

* Environment: development
* Debug mode: on
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: 473-405-251
This version of the application does not contain any Authentication. # Api Reference ## Error Handling Errors are returned as JSON objects in the following format: { "success": False, "error": 400, "message": "Bad request!" }

The API will retern three error types when requests fail:

* 400: Bad Request!
* 404 Resource Not Found
* 422 Not Processable

Endpoints

GET /books

  • Returns a list of book objects, value of success and a total number of books
  • Results are paginated in groups of 8. Include a request argument to choose page number, starting from 1.
  • Sample : In terminal with curl installe type: curl http://127.0.0.1:5000/books
  • Sample Response : { "books": [ { "author": "Petar Deunov", "id": 1, "rating": 10, "title": "Paneurythmy" }, { "author": "Petar Deunov", "id": 3, "rating": 10, "title": "The two ways" }, { "author": "Nikolay Doinov", "id": 5, "rating": 10, "title": "Astrology" } ], "success": true, "total": 3 }

POST /books

  • Creates a new book using the submitted title, author and rating. Return the id of the created book, success value, total vooks and book list based on current page number to update.
  • Example: curl http://127.0.0.1:5000 -X POST -H "Content-Type: application/json" -d '{"title":"Masons", "author":"Jean Palu", "rating":"5"}'
  • Example response: { "books": [ { "author": "Petar Deunov", "id": 1, "rating": 10, "title": "Paneurythmy" }, { "author": "Petar Deunov", "id": 3, "rating": 10, "title": "The two ways" }, { "author": "Nikolay Doinov", "id": 5, "rating": 10, "title": "Astrology" }, { "author": "Jean Palu", "id": 6, "rating": 5, "title": "Masons" } ], "created": 6, "success": true, "total_books": 4 }

DELETE /books/{book_id}

  • Deletes a selected book id. Returns books, success value, total length and deleted id.
  • Example: curl -X DELETE http://127.0.0.1:5000/books/6
  • Example Response: { "books": [ { "author": "Petar Deunov", "id": 1, "rating": 10, "title": "Paneurythmy" }, { "author": "Petar Deunov", "id": 3, "rating": 10, "title": "The two ways" }, { "author": "Nikolay Doinov", "id": 5, "rating": 10, "title": "Astrology" } ], "deleted": 6, "success": true, "total_books": 3 }

PATCH /books/{book_id}

  • If provided, updates rating of the specific book_id. Return success value and id of the updated Book.
  • Example: curl -X PATCH http://127.0.0.1:5000/books/5 -H "Content-Type: application/json" -d '{"rating":"11"}'
  • Example Response: { "id": 5, "success": true }

About

Back-end Application developed in Python and SQLAlchemy with a RESTful API, Unit Tests and API tests

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0