- Python 3.12.5 (If running from host machine)
- Flask (If running from host machine)
- Docker (If running from Docker)
- Call https://jsonplaceholder.typicode.com/users to get list of users
- Format response by including only relevant attributes (id, names, usernames, email and company_names)
- Store formatted response into a list
- Note: I opted for a list in this case since (I assume) all users id are generated and ordered during creation. This speeds up the runtime as specific user id can be directly referenced by the index instead of iterating thru the list.
- Add handler for /users/all
- Add handler for /users/
- As mentioned before, we do not need to do any searching as specific ids can be directly accessed from the list index (users id = index + 1)
- Install Python
- Clone and navigate to Git Repository
- OPTIONAL: Activate virtual environment
- Install required packages:
pip install -r requirements.txt
- Run application:
python3 index.py
orpy index.py
- Access http://127.0.0.1:5656/users/all or http://127.0.0.1:5656/users/ from your web browser - Alternatively you can also use cURL:
curl --location 'http://localhost:5656/users/all'
orcurl --location 'http://localhost:5656/users/<id>'
- Install Docker
- Clone and navigate to Git Repository
- Build Docker image:
sudo docker build . -t ibm-assignment/web-app
- Run Docker container:
sudo docker run -p 127.0.0.1:5656:5656 -d ibm-assignment/web-app
- Assume that endpoint is only accessible from localhost. To expose the application to external networks, use:
sudo docker run -p 5656:5656 -d ibm-assignment/web-app
- Assume that endpoint is only accessible from localhost. To expose the application to external networks, use:
- Access endpoint via cURL:
curl --location 'http://localhost:5656/users/all'
orcurl --location 'http://localhost:5656/users/<id>'
- Install Docker
- Pull Docker image:
sudo docker pull projectquartz/ibm-assignment:latest
- Run Docker container:
sudo docker run -p 127.0.0.1:5656:5656 -d projectquartz/ibm-assignment:latest
- Assume that endpoint is only accessible from localhost. To expose the application to external networks, use:
sudo docker run -p 5656:5656 -d projectquartz/ibm-assignment:latest
- Assume that endpoint is only accessible from localhost. To expose the application to external networks, use:
- Access endpoint via cURL:
curl --location 'http://localhost:5656/users/all'
orcurl --location 'http://localhost:5656/users/<id>'