This API shows how to set up Fast API with mongo db
-
Download and install docker desktop
For windows Docker
For linux Docker
For Mac Docker
-
create a
.env
file with the following variablesMONGO_USERNAME=enter_mongo_db_username MONGO_PASSWORD=enter_mongo_db_password ME_ADMINUSERNAME=enter_mongo_db_express_username ME_ADMINPASSWORD=enter_mongo_db_express_password ME_MONGODB_URL=mongodb://username:password@mongo:27017/ TITLE=enter_your_title_api
Replace
username
andpassword
inME_MONGODB_URL
with your mongo username and mongo password respectively. -
open command prompt or terminal.
Run
docker-compose -f docker-compose.dev.yml
This will start the containers -
Open your browser
This will open mongo express.
Create a database and a collection inside mongo express
-
Run http://localhost:8000/docs to open the interactive swagger UI.