Question: Show me the steps to solve in python: Create a new python file called main _ controller.py and set up your FastAPI ) variable. Global
Show me the steps to solve in python:
Create a new python file called maincontroller.py and set up your FastAPI variable.
Global List
After you created the appFastAPI variable for our API you need to declare our global list of products. We are using a list for now as our database.
In future assignments we will be integrating a database and not be using the list.
List of Products
Products Name: 'Apple', 'Price': 'Type': 'Fruit'
Name: 'Orange', 'Price': 'Type': 'Fruit'
Name: 'Tomato', 'Price': 'Type': 'Fruit'
Name: 'Cabbage', 'Price': 'Type': 'Vegetable'
Name: 'Potato', 'Price': 'Type': 'Vegetable'
Name: 'Potato', 'Price': 'Type': 'Vegetable'
Endpoints
Write a function that is mapped to the following endpoint: product
o Type: GET
o Method Name: getproducts
o Parameters: product price: float REQUIRED producttype: str OPTIONAL
o product name: str OPTIONAL
The above method should return a list of products based on request parameters. If on parameter is present then return everything that matches values of that parameters. If two parameters are present then return everything that matches both values and so on
o
productprice
Write a function that is mapped to the following endpoint: productsprice
o Type: GET
o Method Name: getall products
o Parameters: minprice: float REQUIRED maxprice: float REQUIRED
The above method should return a list of products based on the two parameters min and max prices. Any product that is less than max but greater than min should be returned.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
