This repository contains a Flask application that enables CRUD (Create, Read, Update, Delete) operations on a MongoDB database for a User resource using a REST API. The application's REST API endpoints are accessible via HTTP requests and can be tested using Postman.
Before running the application, make sure you have the following prerequisites installed on your system:
- Python (3.6 or higher)
- Flask
- PyMongo
- Postman (for testing the REST API endpoints)
- Docker (optional, for containerization)
-
Clone the repository
Use Git to clone this repository to your local machine:
git clone https://github.com/s-chandr/CoRider.git cd flask-mongodb-crud
-
Install all the required packages
pip install -r requirements.txt
- Set up a .env file to read the environment variables and paste the below lines
DATABASE_URI = mongodb+srv://<username>:<password>@<cluster>.mongodb.net/?retryWrites=true&w=majority
replace with your creds generate from mongo atlas.
- Finally, run the wsgi application
python wsgi.py
- Docker container :
docker pull schandrdocker/corider-flask-v2
Endpoint: GET /sme/users
Endpoint: GET /sme/users/<id>
Returns the user with the specified ID.
Endpoint: POST /sme/users
Creates a new user with the specified data.
Endpoint: PUT /sme/users/<id>
Updates the user with the specified ID with the new data.
Endpoint: DELETE /sme/users/<id>