This is a simple Python API Server using POST to save data to MongoDB and GET requests to receive the data from MongoDB.
Before you begin, ensure you have met the following requirements:
- You have installed Python 3.6 or higher.
- You have a basic understanding of Python projects and virtual environments.
To avoid conflicts with other Python projects you may be working on, it's a good idea to use a virtual environment. Here's how you can set one up:
For macOS and Linux:
python3 -m venv venv
source venv/bin/activate
For Windows:
python -m venv venv
.\venv\Scripts\activate
Once your virtual environment is activated, install the project dependencies by running:
pip install -r requirements.txt
To start the server, run:
python app.py
Ensure your MongoDB instance is running and accessible as configured in your Python script.
docker run --name mongodb-container -d -p 27017:27017 -v my_mongo_data:/data/db mongo:latest
To interact with the application, you can use the following curl
command to create a new item in the database:
curl -X POST http://localhost:3000/items \
-H "Content-Type: application/json" \
-d '{"id": "4", "name": "maziar"}'
Contributions to enhance the project are welcome. Please fork the repository and create a pull request.
This project is licensed under the GPLv3.