To set up a virtual environment for this application, follow these steps:
-
Open a command prompt at the root of the application's folder (REDLAB).
-
Create a directory named venv:
mkdir venv
-
Navigate into 'venv
cd venv
-
create a virtual enviroment named 'redilab' using Python's 'venv' module:
python -m venv redilab
-
activate the virtual enviroment
on Windows:
venv/Scripts/activate
on macOS/Linux
venv/bin/activate
-
Install the backend dependencies
pip install -r requirements.txt
-
Open a command prompt at the root of the application's folder.
-
add a new .env file and then the codes in the env.simple in . env
-
Run:
docker-compose up -d --build
-
View Container:
docker ps
-
Go inside a Container:
docker exec -it <nodeContainerID> sh
(replace ) -
Stop containers :
docker-compose down
-
Stop all running Containers:
docker stop $(docker ps -aq)
-
remove all Containers:
docker rm $(docker ps -aq)
- Start the FastAPI server:
docker-compose up --build
- Access Swagger UI:
Open your browser and navigate to http://localhost:8000/docs to access the Swagger UI documentation.
- Register User
URL: /user/register
Method: POST
- Login User
URL: /user/login
Method: POST
- Get User Details
URL: /user/{user_id}
Method: GET
Headers:
Authorization: Bearer token for authentication.
Response: The user's details excluding the password.
This application uses MongoDB as the database. Follow these steps to set up MongoDB:
Install MongoDB:
Visit the MongoDB Download Center and follow the instructions to install MongoDB on your system.
Install MongoDB Compass:
Download and install MongoDB Compass, a GUI for MongoDB, to visualize and manage your MongoDB data.
Download and install Docker Desktop for your operating system.
Download and install Postman to test and interact with your API endpoints.
Managing MongoDB with Docker This application uses Docker to manage MongoDB. The docker-compose.yml file includes the configuration for the MongoDB service.
Postman can be used to test the endpoints of the application. Here's how:
Open Postman. Create a new request and set the appropriate method (GET, POST, etc.) and URL. Add headers and body as needed. Send the request and view the response.