This project demonstrates a simple Flask application that integrates with MongoDB to provide a RESTful API for performing CRUD (Create, Read, Update, Delete) operations on a collection of resources.
Before running the application, ensure you have the following installed:
- Python (version 3.6 or higher)
- Flask (version 2.0.0 or higher)
- pymongo (version 3.11.4 or higher)
- MongoDB (version 4.4 or higher)
Follow these instructions to get a copy of the project up and running on your local machine for development and testing purposes.
- Clone this repository
https://github.com/divyanshkumarworks/Flask-Application.git
- go inside clone folder
cd Flask-Application
- Create a Virtual Environment
python -m venv venv
- Activate the environment
source /venv/bin/activate
- install all dependencies:
python -m pip install -r requirements.txt
- Run the Flask application.
python app.py
The application will be accessible at http://localhost:5000.
Note: This project need a Mongodb atlas
account for accessing the database. you can create your MongoDB atlas account in official MongoDB website here: https://www.mongodb.com/basics/mongodb-atlas-tutorial
The following API endpoints are available:
POST /users
Create a new user. (Request body should contain the resource data in JSON format.)GET /users
Fetch all users from the database.GET /users/<id>
Fetch a specific user by its unique identifier (ID).DELETE /users/<id>
Delete a user with the specified ID.PUT /users/<id>
Update an existing user identified by its ID. (Request body should contain the updated resource data in JSON format.)
Special thanks to the Flask and MongoDB communities for their excellent documentation and resources.
If you have any questions or issues, please feel free to open an issue on the repository. Happy coding!