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 main_controller.py and set up your FastAPI) variable.
Global List
After you created the app-FastAPI) 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': 5.99, 'Type': 'Fruit'},
{'Name': 'Orange', 'Price': 6.99, 'Type': 'Fruit'},
{'Name': 'Tomato', 'Price': 7.99, 'Type': 'Fruit'},
{'Name': 'Cabbage', 'Price': 1.99, 'Type': 'Vegetable'},
{'Name': 'Potato', 'Price': 2.50, 'Type': 'Vegetable'},
{'Name': 'Potato', 'Price': 2.50, 'Type': 'Vegetable'}]
Endpoints
Write a function that is mapped to the following endpoint: "/product"
o Type: GET
o Method Name: get_products
o Parameters: product_ price: float (REQUIRED), product_type: 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
/product/price
Write a function that is mapped to the following endpoint: "/products/price"
o Type: GET
o Method Name: get_all products
o Parameters: min_price: float (REQUIRED), max_price: 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!