This is a simple fastApi CRUD app with MongoDB integration as the database that allows for performing CRUD (create,retrieve, update, and delete) on Student information.
Before you begin, ensure you have met the following requirements:
- Python 3.x installed.
- Pip package manager installed.
- A code editor (e.g., VSCode) for development.
- MongoDB install on your system.
-
Clone the repository:
https://github.com/Pundit4Real/Fastapi-MongoDB-CRUD_app.git
-
Create a virtual environment (recommended):
python -m venv ('environment name')
-
Activate the virtual environment:
- On Windows: venv\Scripts\activate - On macOS and Linux: source venv/bin/activate
-
Install the required dependencies:
pip install -r requirements.txt
With MongoDB install on your system;
create a directory called config. Inside the config directory, create a file called database.py which will contain all the database connection codes.
Write this line of code in your database.py file to establish the connection with MongoDB server.
from pymongo import MongoClient
connection = MongoClient("mongodb://localhost:27017/student")
To start the server, run the following commands;
uvicorn your_app_name:app --reload
or
python -m uvicorn your_app_name:app --reload
Replace your_app_name with the actual name of your FastAPI application file.
The endpoint will be available at http://127.0.0.1:8000/docs