https://github.com/optimized-brain/flask-mongodb-crud-api
RESTful API for CRUD operations using Flask and MongoDB
https://github.com/optimized-brain/flask-mongodb-crud-api
crud docker flask mongodb restful-api
Last synced: 28 days ago
JSON representation
RESTful API for CRUD operations using Flask and MongoDB
- Host: GitHub
- URL: https://github.com/optimized-brain/flask-mongodb-crud-api
- Owner: Optimized-Brain
- Created: 2025-06-19T10:59:49.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-06-19T12:08:23.000Z (12 months ago)
- Last Synced: 2025-06-19T13:19:59.048Z (12 months ago)
- Topics: crud, docker, flask, mongodb, restful-api
- Language: Python
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Flask MongoDB CRUD API
A simple RESTful API built with Flask and MongoDB, supporting basic CRUD operations easily deployable with docker
## 🛠️ Tech Stack
- Python 3.x
- Flask
- MongoDB
- Flask-PyMongo
- Docker
## Prerequisites
- [Docker](https://www.docker.com/get-started/)
- [Python 3.x](https://www.python.org/downloads/) and [MongoDB](https://fastdl.mongodb.org/windows/mongodb-windows-x86_64-8.0.10-signed.msi) (Optional for running it locally)
---
## Installation & Running
### with Docker
1. Clone the repo
```powershell
git clone https://github.com/Optimized-Brain/Flask-MongoDB-CRUD-API.git
cd Flask-MongoDB-CRUD-API
```
2. Start services
```powershell
docker-compose up --build
```
### Without Docker
1. Create and activate a virtualenv:
```
python3 -m venv venv
source venv/bin/activate
```
2. Install required dependencies.
```
pip install -r requirements.txt
```
3. Create and Connect local server of MongoDB.
4. Configure MONGO_URI in app.py accordingly.
5. Run app.py
```
python app.py
```
---
## API Reference
| Method | Endpoint | Description | Required Parameters |
| ------ | ------------- | ------------------------------- | ---------------------------------------------------------- |
| POST | `/users` | Create a new user | `name`, `email`, `password` *(in JSON)* |
| GET | `/users` | Get a list of all users | *None* |
| GET | `/users/` | Retrieve a single user by `_id` | `id` (MongoDB ObjectId in URL) |
| PUT | `/users/` | Update an existing user | `id` (in URL), `name/email/password` *(in JSON)* |
| DELETE | `/users/` | Delete a user by `_id` | `id` (MongoDB ObjectId in URL) |