A Flask application that provides a RESTful API for performing CRUD operations on a User resource using a MongoDB database. *above code is final draft for complete workflow checkout https://github.com/udaybadhe/assessment
This Flask application provides REST API endpoints to perform CRUD operations (Create, Read, Update, Delete) on a User resource. The application uses the PyMongo library to connect to a MongoDB database and interact with the User collection.
- Python 3.x
- Flask
- PyMongo
- python-dotenv
- Clone the repository:
git clone https://github.com/your-username/flask-mongodb-crud.git
cd flask-mongodb-crud
- Create a virtual environment and activate it:
python -m venv venv
source venv/bin/activate
- Install the required packages:
pip install -r requirements.txt
- Create a MongoDB database and collection for the application. Update the MongoDB URI and database name in the
.env
file (create one if not present):
MONGODB_URI=mongodb://your-mongodb-uri
DATABASE_NAME=your-database-name
- Run the Flask application:
python app.py
The Flask application will run locally at http://localhost:5000/
. You can use tools like Postman or curl
to interact with the REST API endpoints.
Returns a list of all users.
Returns the user with the specified ID.
Creates a new user with the specified data.
Updates the user with the specified ID with the new data.
Deletes the user with the specified ID.
- Flask
- PyMongo
- python-dotenv