Skip to content

In this coding assignment I have implemented a CRUD (Create, Read, Update, Delete) API with a database deployed in Heroku Postgresql. To implement this assignment I have used Django framework and have deployed the API on Heroku cloud hosting provider. I have created a sample dataset for books with name, isbn, authors, country, number_of_pages, p…

Notifications You must be signed in to change notification settings

balaji2245/django_project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python API Development Assignment

Short description

In this coding assignment I have implemented a CRUD (Create, Read, Update, Delete) API with a database deployed in Heroku Postgresql. To implement this assignment I have used Django framework and have deployed the API on Heroku cloud hosting provider. I have created a sample dataset for books with name, isbn, authors, country, number_of_pages, publisher release_date as its attributes.

You can access the API using following API call:

https://balajibookmanagementapp.herokuapp.com/api/book/

Walkthrough

I have deployed the working API on Heroku, you can see use following website to look at its woking:

https://balajibookmanagementapp.herokuapp.com/api/book/

The backend dataset which I have used is postgresql deployed on Heroku cloud platform. You can add, read, update or delete any record from the dataset. Below I have given examples for the CRUD operations which you can perform on the dataset.

Create

For creating a new Book record, you can either use above mentioned website and add the record as shown in the adjacent screenshot using UI provided or you can as well use an API testing tool like Postman.

1

Or you can use Postman as shown below to create a new book record:

2

Read

For reading the book dataset which I have uploaded on Heroku postgresql cloud services, we can hit the API using above given link and can get the response in JSon as shown below:

3

Or you can use Postman as shown below to read the books dataset:

4

You can also fetch a particular book info with by providing the book id as below:

6

Same thing we can do using Postman or any other API testing tool as well:

5

Update

As shown below, we can update a record by calling the API by "https://balajibookmanagementapp.herokuapp.com/api/book/4/" and using PUT option given at the bottom as follows:

7_1

To update a record in our dataset we can call our API using PUT method as shown below, here I have changed the ISBN number of book named "balaji book".

7

Delete

We can delete a record from the dataset by by calling the API as follows, for example here I've tried deleting the book record with id 1 by calling

https://balajibookmanagementapp.herokuapp.com/api/book/1/

we get an option to delete it as shown in the screenshot below:

8_1

Or we can also use Postman to delete a record from our dataset, we need to call our API using DELETE method which I have shown below:

8

Thus, after deleting 8th record we have our dataset as follows:

9

Setup

The first thing to do is to clone the repository:

$ git clone https://github.com/balaji2245/django_project.git

Create a virtual environment to install dependencies in and activate it:

$ virtualenv2 --no-site-packages env
$ source env/bin/activate

Then install the dependencies:

(env)$ pip install -r requirements.txt

Note the (env) in front of the prompt. This indicates that this terminal session operates in a virtual environment set up by virtualenv2.

Once pip has finished downloading the dependencies:

(env)$ cd project
(env)$ python manage.py runserver

And navigate to http://127.0.0.1:8000/balaji2245/.

About

In this coding assignment I have implemented a CRUD (Create, Read, Update, Delete) API with a database deployed in Heroku Postgresql. To implement this assignment I have used Django framework and have deployed the API on Heroku cloud hosting provider. I have created a sample dataset for books with name, isbn, authors, country, number_of_pages, p…

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published