Skip to content

sumitsingh6/crud-assignment-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Assignment: CRUD Api

A Flask application that performs CRUD (Create, Read, Update, Delete) operations on a MongoDB database for a User resource using a REST API

Using docker to run

Make sure you have docker installed in your machine. To check if docker is installed run docker --version

then to execute this app run: docker run -p 8000:8000 sumitkrsingh98/crud-python-app

The REST API

Host: http://127.0.0.1:8000

1. To fetch all the users from the database

GET /users

Response:

[{"_id":{"$oid":"id123"},"name":"user1","email":"user1@user1.com","password":"pass1"},{"_id":{"$oid":"id124"},"name":"user2","email":"user2@user2.com","password":"pass2"}]

enter image description here

2. To return the user with the specified ID

GET /users/<id>

Response [{"_id":"$oid":"id123"},"name":"user1","email":"user1@user1.com","password":"pass1"}]

enter image description here

3. To create a new user with the specified data

POST /users

Response {"acknowledged":true,"inserted_id":"userid"}

enter image description here

4. To update a user with the specified ID with the new data.

PUT /users/<id>

Body {"name":"Test1","email":"test@testupdate.com","password":"password update"}

(only add fields that needs to be updated )

Response {"acknowledged":true,"matched_count":1,"modified_count":1,"upserted_id":null}

enter image description here

5. Deletes the user with the specified ID

DELETE /users/<id>

Response: {"acknowledged":true,"deleted_count":1}

enter image description here

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published