Now it is time for you to build your own request responses!
You are working for a company that manages contracts between two parties. You need to manage sensitive data, and as such, you need to build two requests:
- One for customer information
- One for contract information
You will be using two new response codes:
- 204: Successful response but no data to send (e.g., confirming a customer exists without sharing data).
- 404: Not found — we cannot find the requested data.
Build the following routes:
/contract/<id>
/customer/<customer_name>
-
GET /contract/<id>
- 200: Contract found — return contract information.
- 404: Contract not found.
-
GET /customer/<customer_name>
- 204: Customer found — no information returned (sensitive).
- 404: Customer not found.
- Initialize Flask
- Set up routes
- Configure responses
- Debug and test during development using the provided test suite and Flask instance.
- Commit as you go with meaningful messages.
- Push commit history to GitHub periodically and when the lab is complete.
- GitHub Repo: Link to be provided
- Flask Quickstart: https://flask.palletsprojects.com/en/stable/quickstart/
Before coding:
-
Fork and Clone
- Go to the provided GitHub repository link.
- Fork the repository to your GitHub account.
- Clone the forked repository to your local machine.
-
Open and Run
- Open the project in VSCode.
- Run
pipenv install
to install dependencies. - Run
pipenv shell
to activate the Python shell.
Build the following routes:
/contract/<id>
/customer/<customer_name>
-
/contract/<id>
- 200: Contract found — return information
- 404: Contract not found
-
/customer/<customer_name>
- 204: Customer found — return no information
- 404: Customer not found
- Create a feature branch.
- Build the following routes:
- If the contract ID is found in the given array:
- Return contract information with a 200 response.
- If not found:
- Return a 404 response.
- If the customer name is found:
- Return a 204 response with an empty body.
- If not found:
- Return a 404 response.
- Push the feature branch and open a PR on GitHub.
- Merge into
main
.
- Add comments to explain logic and purpose.
- Clarify code intent for other developers.
- Include a screenshot of completed work in the README.
- Update the README to reflect functionality using https://makeareadme.com.
- Delete stale branches on GitHub.
- Remove unnecessary or commented-out code.
- Update
.gitignore
if needed to exclude sensitive data